Skip to content

@yantrix/automata v0.0.2Docs


Yantrix API / @yantrix/automata / TAutomataDispatch

Type Alias: TAutomataDispatch()<StateType, ActionType, ContextType, PayloadType, NewStateType>

ts
type TAutomataDispatch<StateType, ActionType, ContextType, PayloadType, NewStateType>: (action) => ReturnType<TAutomataReducer<StateType, ActionType, ContextType, PayloadType, NewStateType>>;

Represents a dispatch function for an automata, used for dispatching certain Actions to the automata to change its state.

Type Parameters

StateType extends TAutomataBaseStateType

The type of the 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 after the dispatch.

Parameters

action: TAutomataActionPayload<ActionType, PayloadType>

The action payload.

Returns

ReturnType<TAutomataReducer<StateType, ActionType, ContextType, PayloadType, NewStateType>>

The new state of the automata and the updated context.