UNPKG

redux-duck

Version:

Helper function to create Redux modules using the ducks-modular-redux proposal.

20 lines (19 loc) 824 B
declare type AppName = string; declare type DuckName = string; declare type ActionType = string; export declare type FSA<Payload = undefined, Meta = undefined> = { type: ActionType; payload?: Payload; meta?: Meta; error?: boolean; }; declare type CaseFn<State> = (state: State, action?: FSA) => State; declare type Case<State> = { [type: string]: CaseFn<State>; }; export declare function createDuck(name: DuckName, app?: AppName): { defineType: (type: string) => string; createReducer: <State>(cases: Case<State>, defaultState: State) => (state?: State, action?: FSA<undefined, undefined>) => State; createAction: <Payload, Meta = undefined>(type: string, isError?: boolean) => (payload?: Payload | undefined, meta?: Meta | undefined) => FSA<Payload, Meta>; }; export {};