Skip to content

@ue-too/being / index / CompositeState

抽象 クラス: CompositeState<EventPayloadMapping, Context, ParentStates, ChildStates, EventOutputMapping>

定義: hierarchical.ts:106

Composite state that contains a child state machine.

Remarks

A composite state is a state that contains its own internal state machine. When the composite state is active, its child state machine is also active. Events are first handled by the child state machine, and if unhandled, they bubble up to the parent state machine.

typescript
type ParentStates = "IDLE" | "ACTIVE";
type ChildStates = "LOADING" | "READY" | "ERROR";

class ActiveState extends CompositeState<Events, Context, ParentStates, ChildStates> {
  eventReactions = {
    stop: {
      action: () => console.log("Stopping..."),
      defaultTargetState: "IDLE"
    }
  };

  getChildStateMachine() {
    return {
      stateMachine: new TemplateStateMachine(...),
      defaultChildState: "LOADING",
      rememberHistory: true
    };
  }
}

拡張

  • TemplateState<EventPayloadMapping, Context, ParentStates, EventOutputMapping>

型パラメーター

EventPayloadMapping

EventPayloadMapping = any

Event payload mapping

Context

Context extends BaseContext = BaseContext

Context type

ParentStates

ParentStates extends string = string

Parent state names

ChildStates

ChildStates extends string = string

Child state names

EventOutputMapping

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

Event output mapping

コンストラクター

コンストラクター

new CompositeState<EventPayloadMapping, Context, ParentStates, ChildStates, EventOutputMapping>(): CompositeState<EventPayloadMapping, Context, ParentStates, ChildStates, EventOutputMapping>

戻り値

CompositeState<EventPayloadMapping, Context, ParentStates, ChildStates, EventOutputMapping>

継承元

TemplateState.constructor

プロパティ

_childStateMachineConfig

protected _childStateMachineConfig: ChildStateMachineConfig<EventPayloadMapping, Context, ChildStates, EventOutputMapping> | null = null

定義: hierarchical.ts:120


_context

protected _context: Context | null = null

定義: hierarchical.ts:127


_defer

protected _defer: Defer<Context, EventPayloadMapping, ParentStates, EventOutputMapping> | undefined = undefined

定義: interface.ts:855

継承元

TemplateState._defer


_delay

protected _delay: Delay<Context, EventPayloadMapping, ParentStates, EventOutputMapping> | undefined = undefined

定義: interface.ts:851

継承元

TemplateState._delay


_eventGuards

protected _eventGuards: Partial<EventGuards<EventPayloadMapping, States, Context, Guard<Context>>>

定義: interface.ts:846

継承元

TemplateState._eventGuards


_eventReactions

protected _eventReactions: EventReactions<EventPayloadMapping, Context, States, EventOutputMapping>

定義: interface.ts:834

継承元

TemplateState._eventReactions


_guards

protected _guards: Guard<Context>

定義: interface.ts:845

継承元

TemplateState._guards


_historyState

protected _historyState: ChildStates | null = null

定義: hierarchical.ts:126

アクセッサー

delay

署名を取得する

get delay(): Delay<Context, EventPayloadMapping, States, EventOutputMapping> | undefined

定義: interface.ts:884

戻り値

Delay<Context, EventPayloadMapping, States, EventOutputMapping> | undefined

継承元

TemplateState.delay


eventGuards

署名を取得する

get eventGuards(): Partial<EventGuards<EventPayloadMapping, States, Context, Guard<Context>>>

定義: interface.ts:869

戻り値

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

継承元

TemplateState.eventGuards


eventReactions

署名を取得する

get eventReactions(): EventReactions<EventPayloadMapping, Context, States, EventOutputMapping>

定義: interface.ts:875

戻り値

EventReactions<EventPayloadMapping, Context, States, EventOutputMapping>

継承元

TemplateState.eventReactions


guards

署名を取得する

get guards(): Guard<Context>

定義: interface.ts:865

戻り値

Guard<Context>

継承元

TemplateState.guards


handlingEvents

署名を取得する

get handlingEvents(): keyof EventPayloadMapping[]

定義: interface.ts:859

戻り値

keyof EventPayloadMapping[]

継承元

TemplateState.handlingEvents

メソッド

beforeExit()

beforeExit(context, stateMachine, to): void

定義: hierarchical.ts:217

パラメータ

context

Context

stateMachine

StateMachine<EventPayloadMapping, Context, ParentStates, EventOutputMapping>

to

"TERMINAL" | ParentStates

戻り値

void

上書き

TemplateState.beforeExit


getChildStateMachine()

abstract protected getChildStateMachine(): ChildStateMachineConfig<EventPayloadMapping, Context, ChildStates, EventOutputMapping>

定義: hierarchical.ts:133

Returns the configuration for the child state machine. Override this method to provide child state machine setup.

戻り値

ChildStateMachineConfig<EventPayloadMapping, Context, ChildStates, EventOutputMapping>


getCurrentChildState()

getCurrentChildState(): ChildStates | null

定義: hierarchical.ts:143

Gets the current child state, or null if no child state machine is active.

戻り値

ChildStates | null


getStatePath()

getStatePath(parentState): HierarchicalStatePath<ParentStates, ChildStates>

定義: hierarchical.ts:164

Gets the full hierarchical path of the current state.

パラメータ

parentState

ParentStates

戻り値

HierarchicalStatePath<ParentStates, ChildStates>


handles()

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

定義: hierarchical.ts:255

型パラメーター

K

K extends string | number | symbol

パラメータ

args

EventArgs<EventPayloadMapping, K>

context

Context

stateMachine

StateMachine<EventPayloadMapping, Context, ParentStates, EventOutputMapping>

戻り値

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

上書き

TemplateState.handles


uponEnter()

uponEnter(context, stateMachine, from): void

定義: hierarchical.ts:177

パラメータ

context

Context

stateMachine

StateMachine<EventPayloadMapping, Context, ParentStates, EventOutputMapping>

from

"INITIAL" | ParentStates

戻り値

void

上書き

TemplateState.uponEnter