UNPKG

@signalwire/core

Version:
38 lines 2.16 kB
import { Action, AnyAction } from "redux"; import { CaseReducer } from "./createReducer"; import { ActionMatcher, ActionMatcherDescriptionCollection, CaseReducers } from "./createReducer"; export interface TypedActionCreator<Type extends string> { (...args: any[]): Action<Type>; type: Type; } /** * A builder for an action <-> reducer map. * * @public */ export interface ActionReducerMapBuilder<State> { /** * Adds a case reducer to handle a single exact action type. * @remarks * All calls to `builder.addCase` must come before any calls to `builder.addMatcher` or `builder.addDefaultCase`. * @param actionCreator - Either a plain action type string, or an action creator generated by [`createAction`](./createAction) that can be used to determine the action type. * @param reducer - The actual case reducer function. */ addCase<ActionCreator extends TypedActionCreator<string>>(actionCreator: ActionCreator, reducer: CaseReducer<State, ReturnType<ActionCreator>>): ActionReducerMapBuilder<State>; /** * Adds a case reducer to handle a single exact action type. * @remarks * All calls to `builder.addCase` must come before any calls to `builder.addMatcher` or `builder.addDefaultCase`. * @param actionCreator - Either a plain action type string, or an action creator generated by [`createAction`](./createAction) that can be used to determine the action type. * @param reducer - The actual case reducer function. */ addCase<Type extends string, A extends Action<Type>>(type: Type, reducer: CaseReducer<State, A>): ActionReducerMapBuilder<State>; addMatcher<A extends AnyAction>(matcher: ActionMatcher<A> | ((action: AnyAction) => boolean), reducer: CaseReducer<State, A>): Omit<ActionReducerMapBuilder<State>, 'addCase'>; addDefaultCase(reducer: CaseReducer<State, AnyAction>): {}; } export declare function executeReducerBuilderCallback<S>(builderCallback: (builder: ActionReducerMapBuilder<S>) => void): [ CaseReducers<S, any>, ActionMatcherDescriptionCollection<S>, CaseReducer<S, AnyAction> | undefined ]; //# sourceMappingURL=mapBuilders.d.ts.map