Is #hydration a fundamentally synchronous process? Is there value in including async operations in hydration? Is hydration sufficiently distinct from initialization?

I wrote some thoughts about this as relates to the `defer-hydration` #WebComponents community protocol. Would love to hear your thoughts!

https://github.com/webcomponents-cg/community-protocols/issues/48

[defer-hydration] Async hydration · Issue #48 · webcomponents-cg/community-protocols

Since the defer-hydration proposal seems to be moving forward I'd like to start one point of discussion: Is hydration a fundamentally synchronous or asynchronous process? I don't know of a strict, ...

GitHub
@develwithoutacause I don't have an immediate opinion around if this is hydration per se or just a generic initialization concern. But I absolutely love your idea of having a community protocol around when something's officially done with this init phase.

@jaredwhite Yeah I am wondering if it would make more sense to have a separate community protocol for initialization.

I'm very strongly of the opinion that you should never be able to get a reference to an uninitialized object (I think this is sometimes called #RAII?) Unfortunately that ship sailed for web components a long time ago. Constructors are worthless in this context too (and terrible per https://blog.dwac.dev/posts/ctor/). So maybe a protocol around initialization would help, whether that is or isn't `defer-hydration`.

Construct Better - Devel without a Cause

Can programming languages design better constructors? Let us explore modern constructor design, its flaws, and some potential improvements.

@develwithoutacause I had to introduce a special promise for my solution getting Turbo and Declarative Shadow DOM working nicely.

https://github.com/whitefusionhq/turbo-shadow

I think that's a different lifecycle than the one you're describing, but I'm pointing it out because I think in general we could use more promise-based lifecycle conventions.

GitHub - whitefusionhq/turbo-shadow: Provides event handling and an HTMLElement mixin for Declarative Shadow DOM in Hotwire Turbo.

Provides event handling and an HTMLElement mixin for Declarative Shadow DOM in Hotwire Turbo. - GitHub - whitefusionhq/turbo-shadow: Provides event handling and an HTMLElement mixin for Declarative...

GitHub

@jaredwhite Yeah DSD is definitely missing some useful lifecycle methods. I had to do something similar in my #HtmlFragments experimentation, specifically for getting streaming to work correctly.

https://blog.dwac.dev/posts/streamable-html-fragments/#chunked-declarative-shadow-dom

I still maintain we need a hook to know when an element is parsed, but I feel like we're losing that battle.

https://github.com/WICG/webcomponents/issues/809

Streamable HTML Fragments - Devel without a Cause

HTML fragments part 2: Streaming tweets. Search the far corners of web standards to learn how we can *stream* HTML fragments directly into the DOM.