-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the data
parameter of LoadEvent
be a promise instead of a direct value, preventing a waterfall and allowing optimistic UI
#7635
Comments
We can take it a step further and say that the |
+1. This is also related to #7119 (reply in thread) |
I'm not sure this gives us any speed boost given the current semantics: We rerun the shared |
WIP - my work until I realized what I've written down at #7635 (comment)
I don't follow how this is a blocker for #7213 or #7175 (or #7119)? If we do implement some kind of loading skeleton screen mechanism (whether that's in the
The client does know which server So the real question for me is more about ergonomic trade-offs than performance ones. Does needing to do this sort of thing... export async function load({ data }) {
+ const foo = await load_some_stuff();
return {
- ...data,
- foo: await load_some_stuff()
+ ...(await data),
+ foo
};
} ...pay for the ability to prevent waterfalls in cases like this? // src/routes/photo/[id]/+page.js
async function load({ data, params }) {
await preload_image(params.id);
return data;
} |
This is a "blocker" using a hack I was hinting in the description:
I'm trying to make a clear suggestion, so I won't go into details, but my further suggestion is similar to the Will be glad to see if there was such a discussion.
There are cases that you want to query data both from your SvelteKit server and another server (your own other/main backend, or 3rd party service), so this induces waterfall. |
That's... not going to happen 😀 . You're of course free to use something like telefunc inside your shared
If you have a server-only |
Why strictly not? In my suggestion, when the load function is being computed on the server side, calling this "resource provider" is just calling to a async function(in the SvelteKit echo system). The idea is that also the client can call this. You can view these providers as a decomposition of the currently server-only loading function into (atomic?) parts. |
Because that approach involves making multiple independent requests instead of having everything neatly batched up by the framework. The atomicity you describe is a bug, not a feature. Since these resource providers aren't linked to a request, they don't get access to the We discussed this among the maintainers just now and decided that the cases where the current behaviour introduces an unnecessary waterfall are rare enough in practice that the ergonomic tradeoff isn't worth it. In those rare cases it's possible to avoid the waterfall by not having a |
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:
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.
The text was updated successfully, but these errors were encountered: