@yantrix/automata v0.2.0 • Docs
Yantrix API / @yantrix/automata / TAutomataReducer
Type Alias: TAutomataReducer()<StateType, ActionType, ContextType, PayloadType, NewStateType>
ts
type TAutomataReducer<StateType, ActionType, ContextType, PayloadType, NewStateType>: (params) => TAutomataStateContext<NewStateType, ContextType>;Represents a reducer function for an automata, used for changing the state upon the dispatch of a certain Action.
Type Parameters
• StateType extends TAutomataBaseStateType
The type of the current automata state.
• ActionType extends TAutomataBaseActionType
The type of the automata action.
• ContextType extends { [K in StateType]: any } = Record<StateType, any>
The type of the context associated with each state.
• PayloadType extends { [K in ActionType]: any } = Record<ActionType, any>
The type of the payload associated with each action.
• NewStateType extends StateType = StateType
The type of the new state for the automata.
Parameters
• params: TAutomataEvent<StateType, ActionType, ContextType, PayloadType>
The event parameters.
Returns
TAutomataStateContext<NewStateType, ContextType>
The new state that the automata should enter and its updated context.