(
options: MutationStateOptions<TResult> = {},
queryClient?: QueryClient,
)
| 22 | } |
| 23 | |
| 24 | export 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…