Comments (4)
It is, but just not as part of the default cache nor any implemented one. So you have to implement it yourself (it is really easy!)
You just have to create a class that implements this interface: https://github.com/ConsoleTVs/swrev/blob/master/src/cache.ts#L101
You have the default cache that you can just copy at: https://github.com/ConsoleTVs/swrev/blob/master/src/cache.ts#L146.
Now, instead of relying on Map<string, CacheItem>
, you will have to rely on localStorage instead.
Just pass your class to the SWR options: https://github.com/ConsoleTVs/swrev/blob/master/src/options.ts#L17
This is a pretty cool idea tho, I might build that soon.
from sswr.
Oh wow.
I'm not very good at writing it.
Also because I think it's harder than we think.
urql-graphql/urql#699 here you can find an example when I was using urql in another project.
Thay have persistence but also had many problems. E.g.: how to correctly save in the "idle" phase to not block the main thread? What to choose between localstorage and indexeddb (I mean, the limits of both?). How to handle cache periods? How many time to retain data? Should we delete sensitive data?
I can totally be your scrupulous and accurate beta tester.
Please let me know which branch I can use to test. :)
I'll start using sswr in the next few hours anyway.
from sswr.
- https://whatwebcando.today/storage.html
- https://svelte.dev/repl/329d9ab4b27543afaf735acfbc6bbec7?version=3.20.1
- https://stackoverflow.com/questions/56488202/how-to-persist-svelte-store
- https://github.com/andsala/svelte-persistent-store
- https://newbedev.com/how-to-persist-svelte-store
- https://dev.to/danawoodman/svelte-quick-tip-connect-a-store-to-local-storage-4idi
from sswr.
I found this, maybe it can help: https://github.com/Kong/swrv#localstorage
from sswr.
Related Issues (20)
- `data` is `undefined` using reactive query HOT 8
- Expose a method to get the cache? HOT 20
- Do we really need `isValid`? HOT 7
- Dependent fetching just doesn't work? HOT 12
- Support synchronous `fetcher` function HOT 3
- `fetcher` is sometimes ignored and it uses the default `fetch` HOT 1
- If `fetcher` returns `null` the revalidation is ignored HOT 1
- make revalidate() fires immediately? HOT 4
- Add `isValidating` prop HOT 1
- revalidateOnMount missing? HOT 2
- Server side rendering SvelteKit example does not work
- SvelteKit - Named export 'SWR' not found HOT 3
- [HELP] Error: Function called outside component initialization
- Add option for polling interval
- Posible vite4 incompatibility HOT 2
- Multiple SWRs in one component keep resetting each other
- Dependent fetching doesn't revalidate when changing to an already cached value
- Svelte 4 support HOT 2
- Difference to @tanstack/svelte-query HOT 1
- Documentation typo: Global configuration options HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sswr.