-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathIsRestoringExample.svelte
More file actions
36 lines (31 loc) · 1017 Bytes
/
IsRestoringExample.svelte
File metadata and controls
36 lines (31 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<script lang="ts">
import { QueryClient } from '@tanstack/query-core'
import { setIsRestoringContext } from '../../src/context.js'
import { createQueries } from '../../src/index.js'
let {
queryFn1,
queryFn2,
}: {
queryFn1: () => Promise<string>
queryFn2: () => Promise<string>
} = $props()
const queryClient = new QueryClient()
setIsRestoringContext({ current: true })
const result = createQueries(
() => ({
queries: [
{ queryKey: ['restoring-1'], queryFn: queryFn1 },
{ queryKey: ['restoring-2'], queryFn: queryFn2 },
],
}),
() => queryClient,
)
</script>
<div>
<div data-testid="status1">{result[0].status}</div>
<div data-testid="status2">{result[1].status}</div>
<div data-testid="fetchStatus1">{result[0].fetchStatus}</div>
<div data-testid="fetchStatus2">{result[1].fetchStatus}</div>
<div data-testid="data1">{result[0].data ?? 'undefined'}</div>
<div data-testid="data2">{result[1].data ?? 'undefined'}</div>
</div>