Describe the problem
If you have both a server load function and a shared load function, the latter can get the results of the former by reading the data part of the load event.
The problem is that the shared load function (as well as the rendered page) have to wait for the server result of the server load function. This results with two problems:
- Forcing a waterfall by waiting to the server load function results before processing the shared load function, when it can be processed in parallel.
- When not on SSR, this prevents optimistic UI, since the page/layout couldn't start be rendered before the full response of the server. Notice that if you put the entire load logic only inside the shared load function, this optimistic UI mechanism is possible.
Describe the proposed solution
Just change the value of the data parameter to be a promise resolving to the server results. (Yes! Such a simple solution!)
This will also allow optimistic UI since the shared load function (if not in SSR) might decide to pass the promise of data directly to the page/layout component (while avoiding promise unwrapping of SvelteKit of course).
Alternatives considered
Forcefully avoid using server load functions, and only use a shared load function for this relevant context.
Importance
would make my life easier
Additional Information
In some sense it's a "blocker" for the other optimistic UI issues requested in #7213 and #7175.
Describe the problem
If you have both a server load function and a shared load function, the latter can get the results of the former by reading the
datapart of the load event.The problem is that the shared load function (as well as the rendered page) have to wait for the server result of the server load function. This results with two problems:
Describe the proposed solution
Just change the value of the
dataparameter to be a promise resolving to the server results. (Yes! Such a simple solution!)This will also allow optimistic UI since the shared load function (if not in SSR) might decide to pass the promise of
datadirectly to the page/layout component (while avoiding promise unwrapping of SvelteKit of course).Alternatives considered
Forcefully avoid using server load functions, and only use a shared load function for this relevant context.
Importance
would make my life easier
Additional Information
In some sense it's a "blocker" for the other optimistic UI issues requested in #7213 and #7175.