-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathFailureExample.svelte
More file actions
25 lines (19 loc) · 739 Bytes
/
FailureExample.svelte
File metadata and controls
25 lines (19 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<script lang="ts">
import type { QueryClient } from '@tanstack/query-core'
import { createMutation, setQueryClientContext } from '../../src/index.js'
let {
queryClient,
mutationFn,
}: {
queryClient: QueryClient
mutationFn: (value: { count: number }) => Promise<{ count: number }>
} = $props()
let count = $state(0)
setQueryClientContext(queryClient)
const mutation = createMutation(() => ({ mutationFn }))
</script>
<button onclick={() => mutation.mutate({ count: ++count })}>Mutate</button>
<div>Data: {mutation.data?.count ?? 'undefined'}</div>
<div>Status: {mutation.status}</div>
<div>Failure Count: {mutation.failureCount}</div>
<div>Failure Reason: {mutation.failureReason ?? 'undefined'}</div>