declare type SecondArgumentOf = T extends (arg1: any, arg2: infer A, ...args: any[]) => any ? A : undefined; /** * Action Groups are the fundamental components of the Jantix Redux architecture. They consist of a * single action creator and a sub-reducer for handling the created action. * * Multiple action groups are combined into a single module using the `buildModule` function. */ interface ActionGroup { type: ActionType; }, State, SubReducer extends (state: State, action: ReturnType) => State> { actionCreator: ActionCreator; subReducer: SubReducer; } /** * This function takes an object containing an action creator and sub-reducer and binds them * together at the type level to create an action group. At the JavaScript level it just passes * through the object unchanged, but at the type level it facilicates inference of all parts of the * action group and ensures that the types of the action creator and sub-reducer match. */ export declare const buildActionGroup: { type: ActionType; }, State, SubReducer extends (state: State, action: ReturnType) => State>({ actionCreator, subReducer, }: { actionCreator: ActionCreator; subReducer: SubReducer; }) => ActionGroup; declare type AllActionsOf { type: string; }; }; }> = { [K in keyof T]: ReturnType; }; declare type AllActionCreatorsOf { type: string; }; }; }> = { [K in keyof T]: T[K]['actionCreator']; }; declare type AllSubReducersOf any; }; }> = { [K in keyof T]: T[K]['subReducer']; }; /** * Given an object defining a Jantix module, performs static verification of its structure and * returns a narrowed version of it suitable for use in `buildStore`. * * @param initialState The initial state that will be provided to all of the action groups * @param actionGroups The action+sub-reducer pairs that will be grouped together under the created * module and share their state. */ export declare const buildModule: { type: string; }; subReducer: (state: State, action: { type: string; }) => State; }; }>(initialState: State, actionGroups: { [ActionType in keyof ActionGroups]: ActionGroup[keyof ActionGroups], (...args: any[]) => Extract[keyof ActionGroups], { type: ActionType; }>>, State, Extract[keyof ActionGroups], (state: State, action: Extract[keyof ActionGroups], { type: ActionType; }>) => State>>; }) => { initialState: State; actions: { [x: string]: ActionGroup[keyof ActionGroups], (...args: any[]) => Extract[keyof ActionGroups]>, { type: string; }>>, State, Extract[keyof ActionGroups], (state: State, action: Extract[keyof ActionGroups]>, { type: string; }>) => State>>; }; }; /** * Given an object defining the reducers and their internal action creators and sub-reducers, builds a Redux store and * typed functions for interacting with it. * * This function MUST be called with an explicit type parameter of `typeof modules` provided in order to gain fully- * typed results. The syntax for that looks like this: * * ```ts * const yourModules = { ... }; * const { dispatch, getState } = buildStore(yourModules); * ``` * * @param modules The object defining the reducers to construct * @param middleware An optional middleware object to add to the created store */ export declare const buildStore: { type: string; }; subReducer: (state: { [StateKey in keyof Modules]: Modules[StateKey]["initialState"]; }[keyof Modules], action: { type: string; }) => { [StateKey in keyof Modules]: Modules[StateKey]["initialState"]; }[keyof Modules]; }; }; }; }, CustomReducers extends { [key: string]: (state: any, action: { type: string; }) => any; } = {}, CustomState extends { [K in keyof CustomReducers]: ReturnType; } = { [K in keyof CustomReducers]: ReturnType; }>(modules: { [StateKey in keyof Modules]: { initialState: { [StateKey in keyof Modules]: Modules[StateKey]["initialState"]; }[StateKey]; actions: { [ActionType in keyof Modules[StateKey]["actions"]]: ActionGroup[keyof Modules[StateKey]["actions"]], (...args: any[]) => Extract[keyof Modules[StateKey]["actions"]], { type: ActionType; }>>, { [K in keyof Modules]: Modules[K]["initialState"]; }[StateKey], Extract[keyof Modules[StateKey]["actions"]], (state: { [K in keyof Modules]: Modules[K]["initialState"]; }[StateKey], action: Extract[keyof Modules[StateKey]["actions"]], { type: ActionType; }>) => { [K in keyof Modules]: Modules[K]["initialState"]; }[StateKey]>>; }; }; }, middleware?: any, customReducers?: CustomReducers) => { actionCreators: { [StateKey in keyof Modules]: { [ActionType in { [K in keyof Modules[StateKey]["actions"]]: ReturnType["type"]; }[keyof Modules[StateKey]["actions"]]]: Extract { type: ActionType; }>; }; }; dispatch: (action: { [StateKey in keyof Modules]: ReturnType<{ [ActionType in keyof Modules[StateKey]["actions"]]: Modules[StateKey]["actions"][ActionType]["actionCreator"]; }[keyof Modules[StateKey]["actions"]]>; }[keyof Modules] | { [StateKey in keyof CustomReducers]: SecondArgumentOf; }[keyof CustomReducers]) => void; getState: () => { [K in keyof Modules]: Modules[K]["initialState"]; } & CustomState; useSelector: (selector: (state: { [K in keyof Modules]: Modules[K]["initialState"]; } & CustomState) => T, shallowEqual?: (prev: T, cur: T) => boolean) => T; store: import("redux").Store<{}, import("redux").AnyAction> & { dispatch: unknown; }; }; export {};