import { Action, GenericAction, ActionCreatorProps } from "redux-toolbelt"; /** * makeAsyncActionCreator can be very useful to create an action creator * that uses promises and reports its progress to the Redux state * * @template A The type of action the function can responde to * * @param {string} baseName The name of the Action * * @param {(...args: any) => Promise | any} asyncFn * The function to execute when the action is called. * It should return a Promise. When it resolves, it will trigger * the success sub-action and if it rejects it will trigger the failure action * * @param {makeThunkAsyncActionCreator.ArgsMapperFN} argsMapper * Maps the arguments that are passed to the action to the payload * that will be used on the action dispatched when action is called * and the meta that will be used when both the action and it's sub-actions are called * * @param {makeThunkAsyncActionCreator.Options} options * Optional data to pass to the function * - prefix - Defaults to '' * - defaultMeta - Defaults to undefined * * @returns {ThunkAsyncActionCreator} * An action creator that when called and dispatched, it will: * - Dispatch an action with the type of baseName and payload and meta * that are based on the arguments of the call, possibly mapped via argsMapper, if present. * - Call the asyncFn and wait on the Promise it should return. * - If it resolves, the success sub-action is dispatched with the result of the Promise. * - If it rejects, the failure sub-action is dispatched with the error of the Promise. */ export declare function makeThunkAsyncActionCreator( baseName: string, asyncFn: (...args: any) => Promise

| P, argsMapper: makeThunkAsyncActionCreator.ArgsMapperFN, options: makeThunkAsyncActionCreator.Options ): ThunkAsyncActionCreator export type ActionCreator = ( (payload?: any, meta?: any) => GenericAction ) & ActionCreatorProps; export type ThunkAsyncActionCreator = ActionCreator & ThunkAsyncActionCreatorProps export interface ThunkAsyncActionCreatorProps { success: ActionCreator; failure: ActionCreator; progress: ActionCreator; cancel: ActionCreator; } export namespace makeThunkAsyncActionCreator { export interface Options { prefix?: string; defaultMeta?: A['meta']; } export type ArgsMapperFN = (...arg: any) => { payload?: A['payload'], meta?: A['meta'], [name: string]: any } interface DefaultOptions extends Options { argsMapper: ArgsMapperFN } /** * Creates an instance of makeThunkAsyncActionCreator with the predefined options * * @template A The type of action the function can responde to * * @template P The type of data the promise will return * * @param {DefaultsArg} args * Prefefined data to pass to the function * - prefix - Defaults to '' * - defaultMeta - Defaults to undefined * - argsMapper - Maps the arguments that are passed to the action to the payload * @returns * an instance of makeThunkAsyncActionCreator with the specified options */ export function withDefaults(args: DefaultOptions): ( baseName: string, asyncFn: (...args: any) => Promise

| P, options: Options ) => ThunkAsyncActionCreator; } export default makeThunkAsyncActionCreator;