import { ToPublicAction, MovexMasterContextAsQuery } from 'movex-core-util'; import type { Observable, CheckedState, ActionOrActionTupleFromAction, AnyAction, MovexReducer } from 'movex-core-util'; export type DispatchFn = (actionOrActionTupleOrFn: ActionOrActionTupleFromAction | ((mc: MovexMasterContextAsQuery) => ActionOrActionTupleFromAction)) => void; export type DispatchedEventPayload = { next: TCheckedState; prev: TCheckedState; action: ActionOrActionTupleFromAction; reapplyActionToPrevState: (action: TAction) => TCheckedState; }; export type DispatchPublicFn = (actionOrFn: ToPublicAction | ((mc: MovexMasterContextAsQuery) => ActionOrActionTupleFromAction)) => void; /** * Creates the Action Movex Dispatcher * * * @param $checkedState * @param reducer * @param onEvents * @returns */ export declare const createDispatcher: ($checkedState: Observable>, reducer: MovexReducer, onEvents?: { /** * This will be called any time an action got dispatched, even if the state didn't update! * This is in order to have more control at the client's end. where they can easily check * the checksum's or even instance if there was an update * * @param event * @returns */ onDispatched?: ((event: DispatchedEventPayload, TAction>) => void) | undefined; onStateUpdated?: ((event: Pick, TAction>, "action" | "next" | "prev">) => void) | undefined; } | undefined) => { dispatch: DispatchFn; unsubscribe: () => void; };