@@ -4,15 +4,39 @@ const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
4
4
5
5
<script lang="ts" setup>
6
6
import { computed , ref } from ' vue'
7
- import { useQuery } from ' @tanstack/vue-query'
7
+ import {
8
+ useQuery ,
9
+ useQueries ,
10
+ useIsMutating ,
11
+ useIsFetching ,
12
+ useMutationState ,
13
+ } from ' @tanstack/vue-query'
8
14
9
15
const route = useRoute (' /users/[id]' )
10
16
11
17
const simulateError = ref (false )
12
18
19
+ const enabled = ref (false )
20
+
21
+ // const tt = useQueries({
22
+ // queries: [
23
+ // {
24
+ // queryKey: ['random'],
25
+ // queryFn: async () => Math.random(),
26
+ // },
27
+ // {
28
+ // queryKey: ['a'],
29
+ // queryFn: async () => 'a',
30
+ // },
31
+ // ],
32
+ // combine: (res) => [res[0].data?.toFixed(2), res[1].data?.toUpperCase()] as const,
33
+ // })
13
34
const {
14
35
data : tqUser,
15
36
status,
37
+ isLoading,
38
+ isFetching,
39
+ isPending,
16
40
fetchStatus,
17
41
error : tqError,
18
42
refetch,
@@ -34,6 +58,8 @@ const {
34
58
queryKey: [' user-id' , computed (() => route .params .id )],
35
59
staleTime: 5000 ,
36
60
retry: false ,
61
+ refetchOnMount: false ,
62
+ enabled ,
37
63
})
38
64
</script >
39
65
@@ -42,6 +68,11 @@ const {
42
68
<h1 >defineQueryLoader()</h1 >
43
69
<pre >User: {{ route.params.id }}</pre >
44
70
71
+ <label >
72
+ <input type =" checkbox" v-model =" enabled" />
73
+ Enabled
74
+ </label >
75
+
45
76
<fieldset >
46
77
<legend >Controls</legend >
47
78
@@ -64,6 +95,12 @@ const {
64
95
65
96
<p >
66
97
<code >status: {{ status }}</code >
98
+ <br >
99
+ isLoading: {{ isLoading }}
100
+ <br />
101
+ isFetching: {{ isFetching }}
102
+ <br />
103
+ isPending: {{ isPending }}
67
104
<br />
68
105
<code >fetchStatus: {{ fetchStatus }}</code >
69
106
</p >
0 commit comments