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

BaseExample.svelte

23 lines595 Bytes

1<script lang="ts">
2 import { QueryClient } from '@tanstack/query-core'
3 import { createMutation, useIsMutating } from '../../src/index.js'
4 import { sleep } from '@tanstack/query-test-utils'
5​
6 const queryClient = new QueryClient()
7 const isMutating = useIsMutating(undefined, queryClient)
8​
9 const mutation = createMutation(
10 {
11 mutationKey: ['mutation-1'],
12 mutationFn: async () => {
13 await sleep(5)
14 return 'data'
15 },
16 },
17 queryClient,
18 )
19</script>
20​
21<button on:click={() => $mutation.mutate()}>Trigger</button>
22​
23<div>isMutating: {$isMutating}</div>