(action?: Action<TData, TError, TVariables, TOnMutateResult>)
| 159 | } |
| 160 | |
| 161 | #notify(action?: Action<TData, TError, TVariables, TOnMutateResult>): void { |
| 162 | notifyManager.batch(() => { |
| 163 | // First trigger the mutate callbacks |
| 164 | if (this.#mutateOptions && this.hasListeners()) { |
| 165 | const variables = this.#currentResult.variables! |
| 166 | const onMutateResult = this.#currentResult.context |
| 167 | |
| 168 | const context = { |
| 169 | client: this.#client, |
| 170 | meta: this.options.meta, |
| 171 | mutationKey: this.options.mutationKey, |
| 172 | } satisfies MutationFunctionContext |
| 173 | |
| 174 | if (action?.type === 'success') { |
| 175 | this.#mutateOptions.onSuccess?.( |
| 176 | action.data, |
| 177 | variables, |
| 178 | onMutateResult, |
| 179 | context, |
| 180 | ) |
| 181 | this.#mutateOptions.onSettled?.( |
| 182 | action.data, |
| 183 | null, |
| 184 | variables, |
| 185 | onMutateResult, |
| 186 | context, |
| 187 | ) |
| 188 | } else if (action?.type === 'error') { |
| 189 | this.#mutateOptions.onError?.( |
| 190 | action.error, |
| 191 | variables, |
| 192 | onMutateResult, |
| 193 | context, |
| 194 | ) |
| 195 | this.#mutateOptions.onSettled?.( |
| 196 | undefined, |
| 197 | action.error, |
| 198 | variables, |
| 199 | onMutateResult, |
| 200 | context, |
| 201 | ) |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | // Then trigger the listeners |
| 206 | this.listeners.forEach((listener) => { |
| 207 | listener(this.#currentResult) |
| 208 | }) |
| 209 | }) |
| 210 | } |
| 211 | } |
no test coverage detected