Skip to content

Commit d0dea29

Browse files
Tested VueQueryRewind on each example from the tanstack documentation and left comments where the componnets should be added to make testing simple for the end user
1 parent 2f83190 commit d0dea29

File tree

10 files changed

+821
-66
lines changed

10 files changed

+821
-66
lines changed

package-vue-vite/README.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
# Vue 3 + TypeScript + Vite
2-
3-
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
4-
5-
## Recommended Setup
6-
7-
- [VS Code](https://code.visualstudio.com/) + [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (previously Volar) and disable Vetur
8-
9-
- Use [vue-tsc](https://github.com/vuejs/language-tools/tree/master/packages/tsc) for performing the same type checking from the command line, or for generating d.ts files for SFCs.
1+
# VueQueryRewind

package-vue-vite/examples/tanstack-examples/2.7-basic/src/App.vue

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
11
<script lang="ts">
2-
import { defineComponent, ref } from 'vue'
2+
import { defineComponent, ref } from 'vue';
33
4-
import Posts from './Posts.vue'
5-
import Post from './Post.vue'
4+
import Posts from './Posts.vue';
5+
import Post from './Post.vue';
6+
7+
// Import VueQueryRewind
8+
// @ts-ignore
9+
import { VueQueryRewind } from '@react-query-rewind/vue-query-rewind';
610
711
export default defineComponent({
812
name: 'App',
9-
components: { Posts, Post },
13+
// Register VueQueryRewind
14+
components: { Posts, Post, VueQueryRewind },
1015
setup() {
11-
const visitedPosts = ref(new Set())
12-
const isVisited = (id: number) => visitedPosts.value.has(id)
16+
const visitedPosts = ref(new Set());
17+
const isVisited = (id: number) => visitedPosts.value.has(id);
1318
14-
const postId = ref(-1)
19+
const postId = ref(-1);
1520
const setPostId = (id: number) => {
16-
visitedPosts.value.add(id)
17-
postId.value = id
18-
}
21+
visitedPosts.value.add(id);
22+
postId.value = id;
23+
};
1924
2025
return {
2126
isVisited,
2227
postId,
2328
setPostId,
24-
}
29+
};
2530
},
26-
})
31+
});
2732
</script>
2833

2934
<template>
3035
<div>
36+
<!-- Add VueQueryRewind to application -->
37+
<VueQueryRewind />
38+
3139
<h1>Vue Query - Basic</h1>
3240
<p>
3341
As you visit the posts below, you will notice them in a loading state the

package-vue-vite/examples/tanstack-examples/basic/src/App.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
import { defineComponent, ref } from 'vue';
33
import { VueQueryDevtools } from '@tanstack/vue-query-devtools';
44
5-
import { VueQueryRewind } from '@react-query-rewind/vue-query-rewind';
6-
75
import Posts from './Posts.vue';
86
import Post from './Post.vue';
97
8+
// Import VueQueryRewind
9+
// @ts-ignore
10+
import { VueQueryRewind } from '@react-query-rewind/vue-query-rewind';
11+
1012
export default defineComponent({
1113
name: 'App',
14+
// Register VueQueryRewind
1215
components: { Posts, Post, VueQueryDevtools, VueQueryRewind },
1316
setup() {
1417
const visitedPosts = ref(new Set());
@@ -30,6 +33,7 @@ export default defineComponent({
3033
</script>
3134

3235
<template>
36+
<!-- Add VueQueryRewind to application -->
3337
<VueQueryRewind />
3438

3539
<h1>Vue Query - Basic</h1>

package-vue-vite/examples/tanstack-examples/dependent-queries/src/App.vue

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
<script lang="ts">
2-
import { defineComponent, ref } from 'vue'
2+
import { defineComponent, ref } from 'vue';
33
4-
import Posts from './Posts.vue'
5-
import Post from './Post.vue'
4+
import Posts from './Posts.vue';
5+
import Post from './Post.vue';
6+
7+
// Import VueQueryRewind
8+
// @ts-ignore
9+
import { VueQueryRewind } from '@react-query-rewind/vue-query-rewind';
610
711
export default defineComponent({
812
name: 'App',
9-
components: { Posts, Post },
13+
// Register VueQueryRewind
14+
components: { Posts, Post, VueQueryRewind },
1015
setup() {
11-
const visitedPosts = ref(new Set())
12-
const isVisited = (id: number) => visitedPosts.value.has(id)
16+
const visitedPosts = ref(new Set());
17+
const isVisited = (id: number) => visitedPosts.value.has(id);
1318
14-
const postId = ref(-1)
19+
const postId = ref(-1);
1520
const setPostId = (id: number) => {
16-
visitedPosts.value.add(id)
17-
postId.value = id
18-
}
21+
visitedPosts.value.add(id);
22+
postId.value = id;
23+
};
1924
2025
return {
2126
isVisited,
2227
postId,
2328
setPostId,
24-
}
29+
};
2530
},
26-
})
31+
});
2732
</script>
2833

2934
<template>
35+
<!-- Add VueQueryRewind to application -->
36+
<VueQueryRewind />
37+
3038
<h1>Vue Query - Dependent Queries</h1>
3139
<p>
3240
As you visit the posts below, you will notice them in a loading state the
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
<template>
2+
<!-- Add VueQueryRewind to application -->
3+
<VueQueryRewind />
4+
25
<div>{{ data }}</div>
36
</template>
47

58
<script setup lang="ts">
6-
import { useQuery } from '@tanstack/vue-query'
9+
import { useQuery } from '@tanstack/vue-query';
10+
11+
// Import VueQueryRewind
12+
// @ts-ignore
13+
import { VueQueryRewind } from '@react-query-rewind/vue-query-rewind';
714
815
const fetcher = async () =>
9-
await fetch('https://jsonplaceholder.typicode.com/posts').then((response) =>
10-
response.json(),
11-
)
16+
await fetch('https://jsonplaceholder.typicode.com/posts').then(response =>
17+
response.json()
18+
);
1219
13-
const { data, suspense } = useQuery({ queryKey: ['test'], queryFn: fetcher })
20+
const { data, suspense } = useQuery({ queryKey: ['test'], queryFn: fetcher });
1421
15-
await suspense()
22+
await suspense();
1623
</script>

package-vue-vite/examples/tanstack-examples/persister/src/App.vue

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
<script lang="ts">
2-
import { defineComponent, ref } from 'vue'
2+
import { defineComponent, ref } from 'vue';
33
4-
import Posts from './Posts.vue'
5-
import Post from './Post.vue'
4+
import Posts from './Posts.vue';
5+
import Post from './Post.vue';
6+
7+
// Import VueQueryRewind
8+
// @ts-ignore
9+
import { VueQueryRewind } from '@react-query-rewind/vue-query-rewind';
610
711
export default defineComponent({
812
name: 'App',
9-
components: { Posts, Post },
13+
// Register VueQueryRewind
14+
components: { Posts, Post, VueQueryRewind },
1015
setup() {
11-
const visitedPosts = ref(new Set())
12-
const isVisited = (id: number) => visitedPosts.value.has(id)
16+
const visitedPosts = ref(new Set());
17+
const isVisited = (id: number) => visitedPosts.value.has(id);
1318
14-
const postId = ref(-1)
19+
const postId = ref(-1);
1520
const setPostId = (id: number) => {
16-
visitedPosts.value.add(id)
17-
postId.value = id
18-
}
21+
visitedPosts.value.add(id);
22+
postId.value = id;
23+
};
1924
2025
return {
2126
isVisited,
2227
postId,
2328
setPostId,
24-
}
29+
};
2530
},
26-
})
31+
});
2732
</script>
2833

2934
<template>
35+
<!-- Add VueQueryRewind to application -->
36+
<VueQueryRewind />
37+
3038
<h1>Vue Query - Basic</h1>
3139
<p>
3240
As you visit the posts below, you will notice them in a loading state the

package-vue-vite/examples/tanstack-examples/simple/src/App.vue

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,43 @@
11
<script lang="ts">
2-
import { defineComponent } from 'vue'
3-
import { useQuery } from '@tanstack/vue-query'
4-
import { VueQueryDevtools } from '@tanstack/vue-query-devtools'
2+
import { defineComponent } from 'vue';
3+
import { useQuery } from '@tanstack/vue-query';
4+
5+
// Import was throwing a type error so we ignored it - this is from the docs so did not change it
6+
// @ts-ignore
7+
import { VueQueryDevtools } from '@tanstack/vue-query-devtools';
8+
9+
// Import VueQueryRewind
10+
// @ts-ignore
11+
import { VueQueryRewind } from '@react-query-rewind/vue-query-rewind';
512
613
export default defineComponent({
714
name: 'App',
8-
components: { VueQueryDevtools },
15+
// Register VueQueryRewind
16+
components: { VueQueryDevtools, VueQueryRewind },
917
setup() {
1018
const { data, error, isFetching, isPending } = useQuery({
1119
queryKey: ['repoData'],
1220
async queryFn() {
1321
return await fetch('https://api.github.com/repos/Tanstack/query').then(
14-
(response) => response.json(),
15-
)
22+
response => response.json()
23+
);
1624
},
17-
})
25+
});
1826
1927
return {
2028
data,
2129
error,
2230
isFetching,
2331
isPending,
24-
}
32+
};
2533
},
26-
})
34+
});
2735
</script>
2836

2937
<template>
38+
<!-- Add VueQueryRewind to application -->
39+
<VueQueryRewind />
40+
3041
<template v-if="isPending"> Loading... </template>
3142
<template v-else-if="error">
3243
'An error has occurred: {{ error.message }}

0 commit comments

Comments
 (0)