Skip to content

Commit 7f23f46

Browse files
committed
chore: playground
1 parent c68ca6d commit 7f23f46

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

playground/src/pages/users/tq-query.[id].vue

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,39 @@ const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
44

55
<script lang="ts" setup>
66
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'
814
915
const route = useRoute('/users/[id]')
1016
1117
const simulateError = ref(false)
1218
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+
// })
1334
const {
1435
data: tqUser,
1536
status,
37+
isLoading,
38+
isFetching,
39+
isPending,
1640
fetchStatus,
1741
error: tqError,
1842
refetch,
@@ -34,6 +58,8 @@ const {
3458
queryKey: ['user-id', computed(() => route.params.id)],
3559
staleTime: 5000,
3660
retry: false,
61+
refetchOnMount: false,
62+
enabled,
3763
})
3864
</script>
3965

@@ -42,6 +68,11 @@ const {
4268
<h1>defineQueryLoader()</h1>
4369
<pre>User: {{ route.params.id }}</pre>
4470

71+
<label>
72+
<input type="checkbox" v-model="enabled" />
73+
Enabled
74+
</label>
75+
4576
<fieldset>
4677
<legend>Controls</legend>
4778

@@ -64,6 +95,12 @@ const {
6495

6596
<p>
6697
<code>status: {{ status }}</code>
98+
<br>
99+
isLoading: {{ isLoading }}
100+
<br />
101+
isFetching: {{ isFetching }}
102+
<br />
103+
isPending: {{ isPending }}
67104
<br />
68105
<code>fetchStatus: {{ fetchStatus }}</code>
69106
</p>

0 commit comments

Comments
 (0)