Open History to see the last commit
1<script lang="ts">
2 import { QueryClient, QueryClientProvider } from '@tanstack/svelte-query'
3 import { SvelteQueryDevtools } from '@tanstack/svelte-query-devtools'
4 import Post from './lib/Post.svelte'
5 import Posts from './lib/Posts.svelte'
6β
7 const queryClient = new QueryClient()
8β
9 let postId = $state<string | null>(null)
10β
11 const setPostId = (id: string | null) => {
12 postId = id
13 }
14</script>
15β
16<QueryClientProvider client={queryClient}>
17 <p>
18 As you visit the posts below, you will notice them in a loading state the
19 first time you load them. However, after you return to this list and click
20 on any posts you have already visited again, you will see them load
21 instantly and background refresh right before your eyes!
22 <strong>
23 (You may need to throttle your network speed to simulate longer loading
24 sequences)
25 </strong>
26 </p>
27 {#if postId !== null}
28 <Post {postId} {setPostId} />
29 {:else}
30 <Posts {setPostId} />
31 {/if}
32 <SvelteQueryDevtools initialIsOpen />
33</QueryClientProvider>