Skip to content
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

Allow cache serialization and subscribers to know the updated key and type of event #365

Closed
wants to merge 3 commits into from

Conversation

sergiodxa
Copy link
Contributor

@sergiodxa sergiodxa commented May 1, 2020

I'm working on a SWR DevTools with @cristianbgp and being able to serialize the cache (useful to download the current version) and to subscribe to specific keys will make the development way easier.

Right now I have some workarounds, iterating the whole cache to get all the keys for both, serializing and know what changed.

The new subscription function will also help build other libraries like https://github.com/sergiodxa/swr-sync-storage which are currently iterating the whole cache on each change to serialize it.

BTW, in a future PR I would like to make useSWR use cache.subcribe internally to get the updates, this will allow us to easily count active hooks and purge keys without subscribed as attempted in #92

@gaoxiaoliangz
Copy link

What's the latest update on this? Is this PR going to be merged? I really want this feature.

@christian-valadez
Copy link

+1, this feature would be really great to have!

@pacocoursey pacocoursey removed their request for review July 9, 2021 18:19
@sergiodxa sergiodxa closed this Jul 31, 2021
@sergiodxa sergiodxa deleted the improved-cache branch July 31, 2021 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants