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

BaseExample.svelte

24 lines626 Bytes

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