Async data loading on the client #6298
mquandalle
started this conversation in
General
Replies: 2 comments 2 replies
-
One Sveltekit API I can imagine is having two And then we need a way to run |
Beta Was this translation helpful? Give feedback.
2 replies
-
Once you know the client fetch has happened, call I'm not sure if this can only be called via a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I try to implement the following data loading pattern.
I have a page with a title, an image and a comments section :
When the page is accessed directly, it's server-side rendered and the
load
function provide all the required data. So far so good.However on the client, let's say that I already have in memory the
title
andimgUrl
and I want to display the page instantly without waiting for the server to provide the comments section. When the client navigate :page.data = {title, imgUrl, comments: undefined}
__data.json
from the server as usualpage.data = await fetch('__data.json')
I think it's possible to implement this pattern by hand with something like :
But the undisciplined usage of stores, and the creation of an additional endpoint doesn't satisfy me.
There should be a better way, do you have any idea?
Beta Was this translation helpful? Give feedback.
All reactions