| 209 | TVariables, |
| 210 | TOnMutateResult |
| 211 | > = (...args) => { |
| 212 | return outsideZone(() => |
| 213 | untracked(() => { |
| 214 | const observer = observerSignal() |
| 215 | observer.setOptions(optionsSignal()) |
| 216 | pendingInvocations++ |
| 217 | lifecycle.setPending(true) |
| 218 | // Track invocations, not the observer's latest result: reset or a later |
| 219 | // mutation completing must not release work which is still running. |
| 220 | const settled = () => { |
| 221 | pendingInvocations-- |
| 222 | lifecycle.setPending(pendingInvocations > 0) |
| 223 | } |
| 224 | try { |
| 225 | return observer |
| 226 | .mutate(args[0] as TVariables, args[1]) |
| 227 | .finally(settled) |
| 228 | } catch (error) { |
| 229 | settled() |
| 230 | throw error |
| 231 | } |
| 232 | }), |
| 233 | ) |
| 234 | } |
| 235 | |
| 236 | const reset = () => { |
| 237 | outsideZone(() => |