@@ -2,9 +2,10 @@ import { useCallback } from 'react';
2
2
import merge from 'lodash/merge' ;
3
3
4
4
import { useSafeSetState } from '../util/hooks' ;
5
- import { MutationMode } from '../types' ;
5
+ import { MutationMode , OnSuccess , OnFailure } from '../types' ;
6
6
import useDataProvider from './useDataProvider' ;
7
7
import useDataProviderWithDeclarativeSideEffects from './useDataProviderWithDeclarativeSideEffects' ;
8
+ import { DeclarativeSideEffect } from './useDeclarativeSideEffects' ;
8
9
9
10
/**
10
11
* Get a callback to fetch the data provider through Redux, usually for mutations.
@@ -33,8 +34,8 @@ import useDataProviderWithDeclarativeSideEffects from './useDataProviderWithDecl
33
34
* @param {string } options.action Redux action type
34
35
* @param {boolean } options.undoable Set to true to run the mutation locally before calling the dataProvider
35
36
* @param {boolean } options.returnPromise Set to true to return the result promise of the mutation
36
- * @param {Function } options.onSuccess Side effect function to be executed upon success or failure , e.g. { onSuccess: response => refresh() }
37
- * @param {Function } options.onFailure Side effect function to be executed upon failure, e.g. { onFailure: error => notify(error.message) }
37
+ * @param {Function } options.onSuccess Side effect function to be executed upon success, e.g. () => refresh()
38
+ * @param {Function } options.onFailure Side effect function to be executed upon failure, e.g. ( error) => notify(error.message)
38
39
* @param {boolean } options.withDeclarativeSideEffectsSupport Set to true to support legacy side effects e.g. { onSuccess: { refresh: true } }
39
40
*
40
41
* @returns A tuple with the mutation callback and the request state. Destructure as [mutate, { data, total, error, loading, loaded }].
@@ -220,8 +221,8 @@ export interface Mutation {
220
221
export interface MutationOptions {
221
222
action ?: string ;
222
223
returnPromise ?: boolean ;
223
- onSuccess ?: ( response : any ) => any | Object ;
224
- onFailure ?: ( error ?: any ) => any | Object ;
224
+ onSuccess ?: OnSuccess | DeclarativeSideEffect ;
225
+ onFailure ?: OnFailure | DeclarativeSideEffect ;
225
226
withDeclarativeSideEffectsSupport ?: boolean ;
226
227
/** @deprecated use mutationMode: undoable instead */
227
228
undoable ?: boolean ;
0 commit comments