MCPcopy
hub / github.com/TanStack/query / useMutationState

Function useMutationState

packages/svelte-query/src/useMutationState.ts:24–49  ·  view source on GitHub ↗
(
  options: MutationStateOptions<TResult> = {},
  queryClient?: QueryClient,
)

Source from the content-addressed store, hash-verified

22}
23
24export function useMutationState<TResult = MutationState>(
25 options: MutationStateOptions<TResult> = {},
26 queryClient?: QueryClient,
27): Readable<Array<TResult>> {
28 const client = useQueryClient(queryClient)
29 const mutationCache = client.getMutationCache()
30
31 let result = getResult(mutationCache, options)
32
33 const { subscribe } = readable(result, (set) => {
34 return mutationCache.subscribe(
35 notifyManager.batchCalls(() => {
36 const nextResult = replaceEqualDeep(
37 result,
38 getResult(mutationCache, options),
39 )
40 if (result !== nextResult) {
41 result = nextResult
42 set(result)
43 }
44 }),
45 )
46 })
47
48 return { subscribe }
49}

Callers

nothing calls this directly

Calls 6

replaceEqualDeepFunction · 0.90
setFunction · 0.85
getMutationCacheMethod · 0.80
useQueryClientFunction · 0.70
getResultFunction · 0.70
subscribeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…