From: Eduardo San Martin Morote Date: Tue, 20 Jul 2021 17:06:47 +0000 (+0200) Subject: chore: more tests X-Git-Tag: v2.0.0-rc.0~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=041262b3d1e8528c32afaf319b167f28796549bf;p=thirdparty%2Fvuejs%2Fpinia.git chore: more tests --- diff --git a/playground/src/stores/jokes-swrv.ts b/playground/src/stores/jokes-swrv.ts index 6f95b531..376bdb54 100644 --- a/playground/src/stores/jokes-swrv.ts +++ b/playground/src/stores/jokes-swrv.ts @@ -1,4 +1,4 @@ -import { ref, unref, watch } from 'vue' +import { ref, toRaw, unref, watch } from 'vue' import { acceptHMRUpdate, defineStore } from '../../../src' import { getRandomJoke, Joke } from '../views/api/jokes' import useSWRV from 'swrv' @@ -7,18 +7,16 @@ export const useJokesSetup = defineStore('jokes-swrv-setup', () => { // const current = ref(null) const history = ref([]) - const { data, error, isValidating, mutate, revalidate } = useSWRV( - 'jokes', - getRandomJoke - ) + const { data, error, isValidating, mutate } = useSWRV('jokes', getRandomJoke) watch(data, (joke) => { + console.log('changed from within the store', joke) if (joke) { - history.value.push(joke) + history.value.push(toRaw(joke)) } }) - return { current: data, history, fetchJoke: revalidate } + return { current: data, error, history, fetchJoke: mutate } }) if (import.meta.hot) { diff --git a/playground/src/views/swrv.vue b/playground/src/views/swrv.vue index ca976375..98e63fd9 100644 --- a/playground/src/views/swrv.vue +++ b/playground/src/views/swrv.vue @@ -28,7 +28,7 @@