Open History to see the last commit
1<script lang="ts">
2 import type { QueryClient } from '@tanstack/query-core'
3 import { createMutation, setQueryClientContext } from '../../src/index.js'
4 import { sleep } from '@tanstack/query-test-utils'
5β
6 type Props = {
7 queryClient: QueryClient
8 perCallOnSuccess: (...args: Array<unknown>) => void
9 }
10β
11 const { queryClient, perCallOnSuccess }: Props = $props()
12β
13 setQueryClientContext(queryClient)
14β
15 const mutation = createMutation(() => ({
16 mutationFn: (text: string) => sleep(10).then(() => text),
17 }))
18</script>
19β
20<button
21 onclick={() => mutation.mutate('todo', { onSuccess: perCallOnSuccess })}
22>
23 Mutate
24</button>