(
options: MutationStateOptions<TResult> = {},
queryClient?: QueryClient,
)
| 66 | } |
| 67 | |
| 68 | export 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 | } |
no test coverage detected
searching dependent graphs…