-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
breaking changeneeds-decisionNot sure if we want to do this yet, also design work neededNot sure if we want to do this yet, also design work needed
Milestone
Description
Describe the problem
Today the data argument we get in the universal load function is eagerly evaluated
kit/packages/kit/src/runtime/client/client.js
Line 2450 in 94c45b9
| const res = await native_fetch(data_url.href); |
this is mostly fine but it would be cool if instead we could lazily load the server data in the universal load function in case we don't need it.
What this would allow is having the ability to cache something client side and have the server load function be invoked only if we don't have client data...something like this eg.
let cached_data;
export async function load({ data }){
cached_data ??= await data();
return {
...cached_data,
};
}this would basically prevent a trip to the server for data that we might know it's already in the client.
Describe the proposed solution
Turn data in a function so that the user can call that lazily. Obviously in case we don't have an universal load function we should just call it ourselves to pass data to the component.
Alternatives considered
No response
Importance
nice to have
Additional Information
No response
Metadata
Metadata
Assignees
Labels
breaking changeneeds-decisionNot sure if we want to do this yet, also design work neededNot sure if we want to do this yet, also design work needed