Skip to content

@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.

参照

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: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, K extends keyof EventOutputMapping ? 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