import { Reducer as ReduxReducer } from "redux"; import type { RootState } from "./State"; import type { ActionMessage } from "../actions"; import type { ILeafReducer } from "./LeafReducer"; import type { ObservableStore } from "../store/ObservableStore"; /** * Error handler type for root reducer */ export declare type RootReducerErrorHandler = (err: Error, reducer?: ILeafReducer) => void; /** * RootReducer for typedux apps * * Maps leaf reducers and decorated reducers * to the appropriate state functions */ export declare class RootReducer { private store; private rootStateType; private reducers; private handledActionIds; /** * onError ref, allows an error handler to * be assigned to the reducer */ private onError; setOnError(onError: RootReducerErrorHandler): this; /** * Create reducer * * @param rootStateType - type of root state, must be immutable map or record * @param reducers - list of all child reducers * @param store */ constructor(store: ObservableStore, rootStateType?: { new (): S; }, ...reducers: ILeafReducer[]); /** * Create default state * * @param defaultStateValue - if provided then its used as base for inflation * @returns {State} */ defaultState(defaultStateValue?: Partial): S; /** * Create a generic handler for dispatches * * @returns {(state:S, action:ReduxAction)=>S} */ makeGenericHandler(): ReduxReducer; /** * Handle action message * * @param state * @param action * @returns {State} */ handle(state: S, action: ActionMessage): S; } export default RootReducer;