Skip to content
v0.18 のドキュメントを表示しています。最新バージョンは v0.20 です。 最新のドキュメントへ

@ue-too/being / index / HierarchicalStateMachine

クラス: HierarchicalStateMachine<EventPayloadMapping, Context, States, EventOutputMapping> ​

定義: hierarchical.ts:306

Extended state machine that supports hierarchical state paths.

Remarks ​

This class extends TemplateStateMachine to track and expose hierarchical state paths when composite states are used.

拡張 ​

型パラメーター ​

EventPayloadMapping ​

EventPayloadMapping = any

Event payload mapping

Context ​

Context extends BaseContext = BaseContext

Context type

States ​

States extends string = string

State names

EventOutputMapping ​

EventOutputMapping extends Partial<Record<keyof EventPayloadMapping, unknown>> = DefaultOutputMapping<EventPayloadMapping>

Event output mapping

コンストラクター ​

コンストラクター ​

new HierarchicalStateMachine<EventPayloadMapping, Context, States, EventOutputMapping>(states, initialState, context, autoStart): HierarchicalStateMachine<EventPayloadMapping, Context, States, EventOutputMapping>

定義: interface.ts:701

パラメータ ​

states ​

Record<States, State<EventPayloadMapping, Context, States, EventOutputMapping>>

initialState ​

States

context ​

Context

autoStart ​

boolean = true

戻り値 ​

HierarchicalStateMachine<EventPayloadMapping, Context, States, EventOutputMapping>

継承元 ​

TemplateStateMachine.constructor

プロパティ ​

_context ​

protected _context: Context

定義: interface.ts:683

継承元 ​

TemplateStateMachine._context


_currentState ​

protected _currentState: "INITIAL" | "TERMINAL" | States

定義: interface.ts:678

継承元 ​

TemplateStateMachine._currentState


_eventResultCallbacks ​

protected _eventResultCallbacks: EventResultCallback<EventPayloadMapping, Context, States>[]

定義: interface.ts:693

継承元 ​

TemplateStateMachine._eventResultCallbacks


_happensCallbacks ​

protected _happensCallbacks: (args, context) => void[]

定義: interface.ts:686

パラメータ ​

args ​

EventArgs<EventPayloadMapping, string> | EventArgs<EventPayloadMapping, keyof EventPayloadMapping>

context ​

Context

戻り値 ​

void

継承元 ​

TemplateStateMachine._happensCallbacks


_initialState ​

protected _initialState: States

定義: interface.ts:699

継承元 ​

TemplateStateMachine._initialState


_stateChangeCallbacks ​

protected _stateChangeCallbacks: StateChangeCallback<States>[]

定義: interface.ts:685

継承元 ​

TemplateStateMachine._stateChangeCallbacks


_states ​

protected _states: Record<States, State<EventPayloadMapping, Context, States, EventOutputMapping>>

定義: interface.ts:679

継承元 ​

TemplateStateMachine._states


_statesArray ​

protected _statesArray: States[]

定義: interface.ts:684

継承元 ​

TemplateStateMachine._statesArray


_timeouts ​

protected _timeouts: number | undefined = undefined

定義: interface.ts:698

継承元 ​

TemplateStateMachine._timeouts

アクセッサー ​

context ​

署名を取得する ​

get context(): Context

定義: interface.ts:874

Read-only access to the machine's live context object. Optional so existing StateMachine implementations remain valid; TemplateStateMachine always provides it. Intended for tooling/introspection (e.g. visualizers evaluating guards against the current context) — mutate state through events, not through this reference.

戻り値 ​

Context

Read-only access to the machine's live context object. Optional so existing StateMachine implementations remain valid; TemplateStateMachine always provides it. Intended for tooling/introspection (e.g. visualizers evaluating guards against the current context) — mutate state through events, not through this reference.

継承元 ​

TemplateStateMachine.context


currentState ​

署名を取得する ​

get currentState(): "INITIAL" | "TERMINAL" | States

定義: interface.ts:866

戻り値 ​

"INITIAL" | "TERMINAL" | States

継承元 ​

TemplateStateMachine.currentState


possibleStates ​

署名を取得する ​

get possibleStates(): States[]

定義: interface.ts:878

戻り値 ​

States[]

継承元 ​

TemplateStateMachine.possibleStates


states ​

署名を取得する ​

get states(): Record<States, State<EventPayloadMapping, Context, States, EventOutputMapping>>

定義: interface.ts:882

戻り値 ​

Record<States, State<EventPayloadMapping, Context, States, EventOutputMapping>>

継承元 ​

TemplateStateMachine.states

メソッド ​

getActiveStatePath() ​

getActiveStatePath(): string[]

定義: hierarchical.ts:343

Gets all active states in the hierarchy. Returns an array where the first element is the top-level state, and subsequent elements are nested child states.

戻り値 ​

string[]


getCurrentStatePath() ​

getCurrentStatePath(): string

定義: hierarchical.ts:324

Gets the current hierarchical state path. Returns a simple state name for non-composite states, or a dot-notation path for composite states (e.g., "PARENT.CHILD").

戻り値 ​

string


happens() ​

コールシグネチャ ​

happens<K>(...args): EventResult<States, K extends keyof EventOutputMapping ? EventOutputMapping[K<K>] : void>

定義: interface.ts:763

型パラメーター ​
K ​

K extends string | number | symbol

パラメータ ​
args ​

...EventArgs<EventPayloadMapping, K>

戻り値 ​

EventResult<States, K extends keyof EventOutputMapping ? EventOutputMapping[K<K>] : void>

継承元 ​

TemplateStateMachine.happens

コールシグネチャ ​

happens<K>(...args): EventResult<States, unknown>

定義: interface.ts:769

型パラメーター ​
K ​

K extends string

パラメータ ​
args ​

...EventArgs<EventPayloadMapping, K>

戻り値 ​

EventResult<States, unknown>

継承元 ​

TemplateStateMachine.happens


isInStatePath() ​

isInStatePath(path): boolean

定義: hierarchical.ts:368

Checks if the state machine is currently in a specific hierarchical path. Supports both simple state names and dot-notation paths.

パラメータ ​

path ​

string

State path to check (e.g., "PARENT" or "PARENT.CHILD")

戻り値 ​

boolean


onEventResult() ​

onEventResult(callback): () => void

定義: interface.ts:854

Subscribe to every event result. Optional so existing StateMachine implementations remain valid; TemplateStateMachine always provides it. Returns a disposer on implementations that support one. Disposing during a dispatch takes effect starting with the next dispatch, not the one in progress — see EventResultCallback for the exact snapshot-iteration semantics.

パラメータ ​

callback ​

EventResultCallback<EventPayloadMapping, Context, States>

戻り値 ​

(): void

戻り値 ​

void

継承元 ​

TemplateStateMachine.onEventResult


onHappens() ​

onHappens(callback): () => void

定義: interface.ts:836

Subscribe to every happens() call, before the state handles it. Returns a disposer on implementations that support one. Disposing during a dispatch takes effect starting with the next dispatch, not the one in progress — see EventResultCallback for the exact snapshot-iteration semantics.

パラメータ ​

callback ​

(args, context) => void

戻り値 ​

(): void

戻り値 ​

void

継承元 ​

TemplateStateMachine.onHappens


onStateChange() ​

onStateChange(callback): () => void

定義: interface.ts:826

Subscribe to state changes. Returns a disposer on implementations that support one. Disposing during a dispatch takes effect starting with the next dispatch, not the one in progress — see EventResultCallback for the exact snapshot-iteration semantics.

パラメータ ​

callback ​

StateChangeCallback<States>

戻り値 ​

(): void

戻り値 ​

void

継承元 ​

TemplateStateMachine.onStateChange


reset() ​

reset(): void

定義: interface.ts:723

戻り値 ​

void

継承元 ​

TemplateStateMachine.reset


setContext() ​

setContext(context): void

定義: interface.ts:870

パラメータ ​

context ​

Context

戻り値 ​

void

継承元 ​

TemplateStateMachine.setContext


start() ​

start(): void

定義: interface.ts:729

戻り値 ​

void

継承元 ​

TemplateStateMachine.start


switchTo() ​

switchTo(state): void

定義: interface.ts:758

パラメータ ​

state ​

"INITIAL" | "TERMINAL" | States

戻り値 ​

void

継承元 ​

TemplateStateMachine.switchTo


wrapup() ​

wrapup(): void

定義: interface.ts:742

戻り値 ​

void

継承元 ​

TemplateStateMachine.wrapup