import type { ObservableStore } from "../store"; import type { ActionMessage, ActionFactory, ActionRegistration } from "./ActionTypes"; import type { Reducer, State, StateConstructor, StateKey, RootState } from "../reducers"; import type { Dispatch } from "redux"; /** * Base class for action implementations for a given state * */ declare abstract class BaseActionFactory = ActionMessage, K extends StateKey = StateKey, RS extends RootState & { [key in K]: S; } = RootState & { [key in K]: S; }> implements ActionFactory { protected actionMap: Map>; protected store: ObservableStore; readonly stateType: StateConstructor; private pushStoreActions; /** * @inheritDoc */ get actions(): ActionRegistration>[]; /** * @inheritDoc */ getAction(fullName: string): any; /** * @inheritDoc */ getAction(leaf: string, type: string): any; /** * @inheritDoc */ registerAction(reg: ActionRegistration): ActionRegistration; /** * Create a new action factory that consumes and produces a specific * state type * * @param stateType * @param withStore */ protected constructor(stateType: StateConstructor, withStore?: ObservableStore); getStore(): ObservableStore; /** * The leaf served by this implementation */ abstract leaf(): K; /** * Get the current dispatcher * * Implemented for the purpose of thunks * etc where the dispatcher can be augmented * * @returns {Function|(function(any): any)} */ get dispatcher(): Dispatch>; /** * Retrieve the current state using the global * getState or the augmented one * * directly applicable to @see dispatcher * * @returns instance of the state supported by this factory */ get state(): S; /** * withDispatcher creates a new instance of * this action implementation with a * new dispatcher and optionally a new * getState * * @returns {any} * @param newStore */ withStore(newStore: ObservableStore): this; /** * Set the store for action factory * * @param newStore * @return {this} */ setStore(newStore: ObservableStore): this; /** * Create a new action message object that * fits the shape defined by the generic M * * @param id * @param type * @param reducers * @param data * @param args * @param leaf */ newMessage(id: string, leaf: string, type: string, reducers?: Reducer>[], args?: any[], data?: {}): M; /** * setError action applies to all states * * @param error */ setError(error: Error): void; } declare namespace BaseActionFactory { let clazzStore: ObservableStore; function setStore(newClazzStore: ObservableStore): void; } export { BaseActionFactory };