File size: 563 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<script lang="ts">
  import { QueryClient } from '@tanstack/query-core'
  import { createMutation, useIsMutating } from '../../src/index.js'
  import { sleep } from '@tanstack/query-test-utils'

  const queryClient = new QueryClient()
  const isMutating = useIsMutating(undefined, queryClient)

  const mutation = createMutation(
    {
      mutationKey: ['mutation-1'],
      mutationFn: () => sleep(10).then(() => 'data'),
    },
    queryClient,
  )
</script>

<button on:click={() => $mutation.mutate()}>Trigger</button>

<div>isMutating: {$isMutating}</div>