Replies: 1 comment 1 reply
-
Actually I just had an idea to use an "offline loader" component which I can instantiate when the app loads and then tear itself down after the data finishes loading. Some way to to this more elegantly would be nice but I think that should solve it. |
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
Uh oh!
There was an error while loading. Please reload this page.
-
My app needs to have some pieces of data available offline even if the user hasn't gone to a route that actually needs it yet.
Specifically, what I want to do is prefetch certain remote query functions up front when the app loads, so that later if the user is offline, the app will already have those functions' data loaded in the service worker cache even if they haven't gone to a relevant route.
I've tried calling the query function in the root +layout.ts, which works fine for the initial load. But then the query is "active" for the entire lifetime of the app. This means that whenever you go to a route that needs the data, you won't get fresh data because it will just use the value in Svelte's cache.
Here are some possible solutions I've thought of. I think only the last one is actually doable right now though.
untrack(() => getData())
orgetData.fetchOnce()
Is there some way to accomplish this?
Beta Was this translation helpful? Give feedback.
All reactions