Comments (3)
I don't think the use case you're taking about or the example your posted is really hydration in the sense that I know it. You essentially have a component that's already "hydrated" or just doesn't need hydration.
One case where defer-hydration would be critical is if instead of fetching data based on a user-id
attribute, it fetched based on some non-serializable property set by the parent during the parent's hydration. Then you would want to wait until you had the data from the parent to begin the fetch so that you potentially didn't fetch twice and throw away one result. The component could wait to fetch if defer-hydration
is present and fetch when it's removed. This would probably look like it deferring it's normal connected or attribute-changed logic.
Regardless, you have a component that async fetches data, and therefore all of the APIs based on that data need to be designed with that in mind. Whether getFriends()
is async, or there's a promise on the component that resolves when it's ready, etc., would be up to the component. Presumably it has to answer all those questions for client-side rendering too, so there's nothing defer-hyderation
could do to universally answer them.
from community-protocols.
I don't think the use case you're taking about or the example your posted is really hydration in the sense that I know it. You essentially have a component that's already "hydrated" or just doesn't need hydration.
I can see that await fetchUser
is arguably not hydration, but do you also think Number(this.getAttribute('user-id')!)
is not hydrating? The current defer-hydration
proposal is kind of vague on the definition of "hydration" and I proposed a few different interpretations in my first comment. How do you define that term for the purposes of defer-hydration
?
One case where defer-hydration would be critical is if instead of fetching data based on a
user-id
attribute, it fetched based on some non-serializable property set by the parent during the parent's hydration. Then you would want to wait until you had the data from the parent to begin the fetch so that you potentially didn't fetch twice and throw away one result. The component could wait to fetch ifdefer-hydration
is present and fetch when it's removed. This would probably look like it deferring it's normal connected or attribute-changed logic.
Sure, if you believe that is a more compelling use case then I agree async hydration could be just as relevant there. I created a new Stackblitz which demonstrates this exact use case.
I don't personally see defer-hydration
as intrinsically tied to top-down hydration or non-serializable inputs and I don't think this particular issue is all that affected by it.
Regardless, you have a component that async fetches data, and therefore all of the APIs based on that data need to be designed with that in mind. Whether
getFriends()
is async, or there's a promise on the component that resolves when it's ready, etc., would be up to the component. Presumably it has to answer all those questions for client-side rendering too, so there's nothingdefer-hyderation
could do to universally answer them.
I will point out that not all components will support client-side rendering. Server-only components which are progressively enhanced on the client that don't necessitate a re-render step are perfectly viable today. An async form of defer-hydration
could be exactly what such components need to properly interoperate.
That said, I do agree client-side rendering has a very similar initialization problem, and maybe that's a signal that this is something which should be tackled independently of defer-hydration
. Certainly I would want any general solution to initialization to also have a good story as relates to hydration and server-only components in particular.
from community-protocols.
Related Issues (20)
- [context] improve naming of dispose and multiple arguments HOT 1
- [context] supporting cases where provider is defined after consumer HOT 11
- Proposal: Reactive controllers protocol HOT 4
- Support versioning of Web Components HOT 4
- [progressive-hydration] conditions for first level hydration timing HOT 12
- [pending-task] Cancellation mechanism HOT 1
- [progressive hydration] self hydrating custom elements HOT 4
- Compatibility and Interop Specification (Versioning WCs) HOT 4
- [context] Do we *need* `multiple` and `dispose()`? HOT 5
- [defer-hydration] Requesting hydration of a disconnected component HOT 7
- [context] Fully event driven context protocol HOT 7
- [context] Event namespace HOT 8
- [reactivity] Reactivity/Observable/Signals Proposal HOT 19
- [context] Declarative alternative HOT 1
- [context] Some concerns, and an idea of how they could be addressed HOT 16
- [Context] add learnings from the front
- [Proposal] DOM Scope Request Resolution HOT 6
- [Proposal] Registration API HOT 13
- [context] What is the use case for one-off requests?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from community-protocols.