Tags: nahinakbar/swrv
Tags
feat(revalidation) add revalidation in mutate (Kong#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 Kong#16
PreviousNext