Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

BaseExample.svelte

25 lines736 Bytes

1<script lang="ts">
2 import { QueryClient } from '@tanstack/query-core'
3 import { createInfiniteQuery } from '../../src/index.js'
4 import type { QueryObserverResult } from '@tanstack/query-core'
5 import type { Writable } from 'svelte/store'
6 import { sleep } from '@tanstack/query-test-utils'
7​
8 export let states: Writable<Array<QueryObserverResult>>
9​
10 const queryClient = new QueryClient()
11​
12 const query = createInfiniteQuery(
13 {
14 queryKey: ['test'],
15 queryFn: ({ pageParam }) => sleep(10).then(() => pageParam),
16 getNextPageParam: (lastPage) => lastPage + 1,
17 initialPageParam: 0,
18 },
19 queryClient,
20 )
21​
22 $: states.update((prev) => [...prev, $query])
23</script>
24​
25<div>Status: {$query.status}</div>