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

Function useMutationState

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

Source from the content-addressed store, hash-verified

66}
67
68export function useMutationState<TResult = MutationState>(
69 options: MutationStateOptions<TResult> = {},
70 queryClient?: QueryClient,
71): Readonly<Ref<Array<TResult>>> {
72 const filters = computed(() => cloneDeepUnref(options.filters))
73 const mutationCache = (queryClient || useQueryClient()).getMutationCache()
74 const state = shallowRef(getResult(mutationCache, options))
75 const unsubscribe = mutationCache.subscribe(() => {
76 state.value = getResult(mutationCache, options)
77 })
78
79 watch(filters, () => {
80 state.value = getResult(mutationCache, options)
81 })
82
83 onScopeDispose(() => {
84 unsubscribe()
85 })
86
87 return shallowReadonly(state)
88}

Callers 2

useIsMutatingFunction · 0.70

Calls 6

cloneDeepUnrefFunction · 0.90
useQueryClientFunction · 0.90
getMutationCacheMethod · 0.80
getResultFunction · 0.70
unsubscribeFunction · 0.70
subscribeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…