Type Alias EventReactions<EventPayloadMapping, Context, States>

EventReactions: {
    [K in keyof Partial<EventPayloadMapping>]: {
        action: (context: Context, event: EventPayloadMapping[K]) => void;
        defaultTargetState: States;
    }
}

This is the type for the event reactions of a state.

Generic parameters:

  • EventPayloadMapping: A mapping of events to their payloads.
  • Context: The context of the state machine. (which can be used by each state to do calculations that would persist across states)
  • States: All of the possible states that the state machine can be in. e.g. a string literal union like "IDLE" | "SELECTING" | "PAN" | "ZOOM"

Type Parameters

  • EventPayloadMapping
  • Context extends BaseContext
  • States extends string