(
options: MutationObserverOptions<
TData,
TError,
TVariables,
TOnMutateResult
>,
)
| 63 | } |
| 64 | |
| 65 | setOptions( |
| 66 | options: MutationObserverOptions< |
| 67 | TData, |
| 68 | TError, |
| 69 | TVariables, |
| 70 | TOnMutateResult |
| 71 | >, |
| 72 | ) { |
| 73 | const prevOptions = this.options as |
| 74 | | MutationObserverOptions<TData, TError, TVariables, TOnMutateResult> |
| 75 | | undefined |
| 76 | this.options = this.#client.defaultMutationOptions(options) |
| 77 | if (!shallowEqualObjects(this.options, prevOptions)) { |
| 78 | this.#client.getMutationCache().notify({ |
| 79 | type: 'observerOptionsUpdated', |
| 80 | mutation: this.#currentMutation, |
| 81 | observer: this, |
| 82 | }) |
| 83 | } |
| 84 | |
| 85 | if ( |
| 86 | prevOptions?.mutationKey && |
| 87 | this.options.mutationKey && |
| 88 | hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey) |
| 89 | ) { |
| 90 | this.reset() |
| 91 | } else if (this.#currentMutation?.state.status === 'pending') { |
| 92 | this.#currentMutation.setOptions(this.options) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | protected onUnsubscribe(): void { |
| 97 | if (!this.hasListeners()) { |
no test coverage detected