Skip to content

@ue-too/being / index / State

インターフェイス: State<EventPayloadMapping, Context, States, EventOutputMapping> ​

定義: interface.ts:349

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.

参照 ​

TemplateState

型パラメーター ​

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:403


eventGuards ​

eventGuards: Partial<EventGuards<EventPayloadMapping, States, Context, Guard<Context>>>

定義: interface.ts:392


eventPreconditions? ​

optional eventPreconditions: Partial<EventPreconditions<EventPayloadMapping, Context, Guard<Context, string>>>

定義: interface.ts:400

Pre-action vetoes: named guards that must all pass before this state handles an event. Optional so existing State implementations remain valid; TemplateState always provides it.


eventReactions ​

eventReactions: EventReactions<EventPayloadMapping, Context, States, EventOutputMapping>

定義: interface.ts:406


guards ​

guards: Guard<Context>

定義: interface.ts:391

メソッド ​

beforeExit() ​

beforeExit(context, stateMachine, to): void

定義: interface.ts:367

パラメータ ​

context ​

Context

stateMachine ​

StateMachine<EventPayloadMapping, Context, States, EventOutputMapping>

to ​

States | "TERMINAL"

戻り値 ​

void


handles() ​

handles<K>(args, context, stateMachine): EventResult<States, K extends keyof EventOutputMapping ? EventOutputMapping[K<K>] : void>

定義: interface.ts:377

型パラメーター ​

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:357

パラメータ ​

context ​

Context

stateMachine ​

StateMachine<EventPayloadMapping, Context, States, EventOutputMapping>

from ​

States | "INITIAL"

戻り値 ​

void