Replies: 1 comment 1 reply
-
Linking corresponding PR withastro/astro#7071 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
Summary
Allow a parallel rendering for the async components (the Promise-alike components e.g. with top level await)
Background & Motivation
I have several components that fetch data from the server in SSR mode (with top-level await). The components are configured in CMS and mixed altogether in a following manner:
Example:
where the component is similar to this:
If they were fetching the data in parallel, that would be totally fine, however the components are rendered sequentially. That means, every data fetch happens one after another, and instead of 100ms rendering time I would get amountOfFetches * 100ms rendering time which is totally unacceptable.
This should be something similar to a
Promise.all
but inside the template.Possible workaround: the data can be preloaded in a root .astro component and then passed to the children components. This is however not something I can treat as optimal: this propagates the code complexity and excluding the possibility to encapsulate the component logic. Each component should be responsible for fetching the data it requires.
Goals
Example
This could potentially look like
Beta Was this translation helpful? Give feedback.
All reactions