@ue-too/being / index / State
介面: State<EventPayloadMapping, Context, States, EventOutputMapping>
定義於: interface.ts:286
Description
This is the interface for the state. The interface takes in a few generic parameters: You can probably get by extending the TemplateState class.
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"
- EventOutputMapping: A mapping of events to their output types. Defaults to void for all events.
A state's all possible states can be only a subset of the possible states of the state machine. (a state only needs to know what states it can transition to) This allows for a state to be reusable across different state machines.
參閱
型別參數
EventPayloadMapping
EventPayloadMapping
Context
Context extends BaseContext
States
States extends string = "IDLE"
EventOutputMapping
EventOutputMapping extends Partial<Record<keyof EventPayloadMapping, unknown>> = DefaultOutputMapping<EventPayloadMapping>
屬性
delay
delay:
Delay<Context,EventPayloadMapping,States,EventOutputMapping> |undefined
定義於: interface.ts:332
eventGuards
eventGuards:
Partial<EventGuards<EventPayloadMapping,States,Context,Guard<Context>>>
定義於: interface.ts:329
eventReactions
eventReactions:
EventReactions<EventPayloadMapping,Context,States,EventOutputMapping>
定義於: interface.ts:335
guards
guards:
Guard<Context>
定義於: interface.ts:328
方法
beforeExit()
beforeExit(
context,stateMachine,to):void
定義於: interface.ts:304
參數
context
Context
stateMachine
StateMachine<EventPayloadMapping, Context, States, EventOutputMapping>
to
States | "TERMINAL"
回傳
void
handles()
handles<
K>(args,context,stateMachine):EventResult<States,Kextends keyofEventOutputMapping?EventOutputMapping[K<K>] :void>
定義於: interface.ts:314
型別參數
K
K extends string | number | symbol
參數
args
EventArgs<EventPayloadMapping, K>
context
Context
stateMachine
StateMachine<EventPayloadMapping, Context, States, EventOutputMapping>
回傳
EventResult<States, K extends keyof EventOutputMapping ? EventOutputMapping[K<K>] : void>
uponEnter()
uponEnter(
context,stateMachine,from):void
定義於: interface.ts:294
參數
context
Context
stateMachine
StateMachine<EventPayloadMapping, Context, States, EventOutputMapping>
from
States | "INITIAL"
回傳
void