(
options: () => MutationStateOptions<TResult, TMutation> = () => ({}),
)
| 116 | * ``` |
| 117 | */ |
| 118 | export function injectMutationState< |
| 119 | TResult = MutationState, |
| 120 | TMutation extends Mutation<any, any, any, any> = |
| 121 | MutationTypeFromResult<TResult>, |
| 122 | >( |
| 123 | options: () => MutationStateOptions<TResult, TMutation> = () => ({}), |
| 124 | ): Signal<Array<TResult>> { |
| 125 | if (typeof ngDevMode === 'undefined' || ngDevMode) { |
| 126 | assertInInjectionContext(injectMutationState) |
| 127 | } |
| 128 | const queryClient = inject(QueryClient) |
| 129 | const mutationCache = queryClient.getMutationCache() |
| 130 | |
| 131 | return injectExternalStore( |
| 132 | () => ({ |
| 133 | getSnapshot: () => getResult(mutationCache, options()), |
| 134 | subscribe: (onStoreChange) => mutationCache.subscribe(onStoreChange), |
| 135 | }), |
| 136 | { |
| 137 | equal: (previous, next) => |
| 138 | previous.length === next.length && |
| 139 | previous.every((value, index) => Object.is(value, next[index])), |
| 140 | }, |
| 141 | ) |
| 142 | } |
no test coverage detected