Open History to see the last commit
1<script lang="ts">
2 import { onDestroy, onMount } from 'svelte'
3 import { createQuery, setQueryClientContext } from '../../src/index.js'
4 import type { QueryClient } from '@tanstack/query-core'
5 import type { Accessor, CreateQueryOptions } from '../../src/index.js'
6β
7 type Props = {
8 queryClient: QueryClient
9 options1: Accessor<CreateQueryOptions>
10 options2: Accessor<CreateQueryOptions>
11 }
12β
13 let { queryClient, options1, options2 }: Props = $props()
14β
15 setQueryClientContext(queryClient)
16β
17 onMount(() => queryClient.mount())
18 onDestroy(() => queryClient.unmount())
19β
20 const query1 = createQuery(options1)
21 const query2 = createQuery(options2)
22</script>
23β
24<button onclick={() => query1.refetch()}>refetch1</button>
25β
26<div data-testid="status1">{query1.status}</div>
27<div data-testid="fetchStatus1">{query1.fetchStatus}</div>
28<div data-testid="data1">{query1.data ?? 'undefined'}</div>
29<div data-testid="isStale1">{query1.isStale}</div>
30β
31<div data-testid="status2">{query2.status}</div>
32<div data-testid="fetchStatus2">{query2.fetchStatus}</div>
33<div data-testid="data2">{query2.data ?? 'undefined'}</div>
34<div data-testid="isStale2">{query2.isStale}</div>