/** Redux action management utilities. */ import { PutEffect, SelectEffect, CallEffect, TakeEffect, ActionChannelEffect } from "redux-saga/effects"; import { Action, AnyAction, ActionCreator } from "redux"; import { ThunkAction as ThunkActionX } from "redux-thunk"; export { ActionCreator as ActionCreator, Action as Action, AnyAction as AnyAction }; /** Used for functions that we also add the ACTION name to. */ export declare type WithACTION = { ACTION: string; }; export declare type ActionCreatorTypes = MultiActionCreator | WrapperActionCreator | (ActionCreator & WithACTION) | ActionCreator; /** * A multi-action is an object with well-known keys whose values * are action creators. Much the same as redux.ActionCReatorsMapObject. */ export interface MultiActionCreator { [name: string]: ActionCreator & WithACTION; } /** For react-thunk. */ export declare type ThunkAction = ThunkActionX; /** Redux had ActionCreatorsMapObject already there. */ export declare type ActionCreatorsMap = Record | WrapperActionCreator>; /** Action wrapper that has an ACTION label and a subaction data property. */ export interface WrapperActionCreator extends ActionCreator, WithACTION { } /** * Create an action creator. Returns a function that creates an action message * with "type" type and argNames as properties on that message corresponding * to the arguments of the function call. The actual properties are computed * at runtime and hence, we cannot statically make a perfect return type. */ export declare function makeActionCreator(type: string, ...argNames: any[]): ActionCreator; /** * Return an object with well-known keys that have action creators as values. * The returned object has properties from "key" but the * actual message type is under the property ACTION on the creator function and is * made up of the id and key together. * * TODO: Convert to object syntax for input, not goofy array. */ export declare function createActionMap(id: string, prefixes: Array<{ key: string; args: Array; }>): MultiActionCreator; /** * An ActionCreator map with properties that match the names of actions needed * to manage a multi-select like list of values. */ export interface MultiSelectActionCreator extends MultiActionCreator { SET_REFDATA: ActionCreator & WithACTION; SET: ActionCreator & WithACTION; ADD: ActionCreator & WithACTION; REMOVE: ActionCreator & WithACTION; CLEAR: ActionCreator & WithACTION; SET_ALL: ActionCreator & WithACTION; } /** * Create string ids and action creators i.e. Record * * ``` * const choices = createMultiSelect("somechoices") // returns an object * ``` * Dispatching: * ``` * dispatch(choices.SET_REFDATA(actionData)) * ``` * Reducing: * ``` * function reducer(state, action) { ... * case choices.SET_ALL.ACTION: * const data = action.data * ... * } * ``` */ export declare function createMultiSelect(id: string): MultiSelectActionCreator; export interface SingleSelectActionCreator extends MultiActionCreator { SET_REFDATA: ActionCreator & WithACTION; SET: ActionCreator & WithACTION; CLEAR: ActionCreator & WithACTION; } /** * Create a single select set of actions. * This is just a subset of those in a multi select, SET_REFDATA, SET and CLEAR. */ export declare function createSingleSelect(id: any): SingleSelectActionCreator; /** * Create action and type for changing something. Args will be a subaction. * Name on object will be "change.prefix" by default. * * @deprecated Use mkWrapper */ export declare const mkChange: (prefix: string, aname?: string) => WrapperActionCreator; /** * Create action and type for changing something. Args will be a subaction. * Name on object will be "wrapper.prefix". */ export declare const mkWrapper: (prefix: string) => WrapperActionCreator; /** * Make a function from a "filterName" to create a saga * action channel on and a handler to call with the most * recent state. The subaction is dispatched before calling * the handler. You this to track the a message which wraps another * message and that needs to be detected in the saga middleware. * filterName should be called channelName. You still need to call * the returned function. * * @param {string} filterName Name of channel message type. * @param {Function} handler (action,state) => generator * @param {boolean} dispatchSubActon Dispatch subaction before calling the handler. * @return generator */ export declare function mkSubactionSaga(filterName: string, handler: any, dispatchSubaction?: boolean): () => IterableIterator | CallEffect | SelectEffect | ActionChannelEffect>;