From 041262b3d1e8528c32afaf319b167f28796549bf Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Tue, 20 Jul 2021 19:06:47 +0200 Subject: [PATCH] chore: more tests --- playground/src/stores/jokes-swrv.ts | 12 +++++------- playground/src/views/swrv.vue | 9 ++++++++- 2 files changed, 13 insertions(+), 8 deletions(-) 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 @@