| 229 | } |
| 230 | |
| 231 | private executeMutation(): Promise<TData> { |
| 232 | this.retryer = new Retryer({ |
| 233 | fn: () => { |
| 234 | if (!this.options.mutationFn) { |
| 235 | return Promise.reject('No mutationFn found') |
| 236 | } |
| 237 | return this.options.mutationFn(this.state.variables!) |
| 238 | }, |
| 239 | onFail: () => { |
| 240 | this.dispatch({ type: 'failed' }) |
| 241 | }, |
| 242 | onPause: () => { |
| 243 | this.dispatch({ type: 'pause' }) |
| 244 | }, |
| 245 | onContinue: () => { |
| 246 | this.dispatch({ type: 'continue' }) |
| 247 | }, |
| 248 | retry: this.options.retry ?? 0, |
| 249 | retryDelay: this.options.retryDelay, |
| 250 | }) |
| 251 | |
| 252 | return this.retryer.promise |
| 253 | } |
| 254 | |
| 255 | private dispatch(action: Action<TData, TError, TVariables, TContext>): void { |
| 256 | this.state = reducer(this.state, action) |