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