-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(revalidation) add revalidation in mutate (#17)
mutate was only warming the DATA_CACHE and was not triggering revalidations on all swrv instances, so a user could not easily inject data via some async event outside of the context of a useSWRV hook e.g. via websocket event. This adds all the stateRefs into a cache (essentially a Map wrapper) that allows mutate to access the vue reactivity when setting data/error/etc. Since each item in REF_CACHE is reactive, setting their values will trigger rerenders in each useSWRV instance. This introduces a small change to existing functionality that if the fetcherFn is a simple function that resolves immediately e.g. () => 'hello', then the data ref will never be undefined, but will be hello on first render. Fixes #16
- Loading branch information
1 parent
1f9636e
commit d543cba
Showing
2 changed files
with
113 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters