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

BaseExample.svelte

20 lines563 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: () => sleep(10).then(() => 'data'),
13 },
14 queryClient,
15 )
16</script>
17​
18<button on:click={() => $mutation.mutate()}>Trigger</button>
19​
20<div>isMutating: {$isMutating}</div>