@ue-too/being / index / DelegatingState
抽象 クラス: DelegatingState<EventPayloadMapping, Context, States, Child, EventOutputMapping>
A state that hosts a complete child state machine and forwards events to it.
Remarks
This is the composition primitive for nesting one machine inside another. While the parent machine is in a DelegatingState, every event is offered to the child first. When the child handles it, the child's output is returned and the parent stays in this state; the child's own nextState is deliberately dropped because it names a child state, not a parent one. When the child does not handle the event, the state's own _eventReactions get their turn, which is how a subclass declares its exits.
Lifecycle is tied to the parent state: entering starts (or restarts) the child from its initial state, leaving calls wrapup() on it. Subclasses that override uponEnter or beforeExit must call super.
例
class MoveState extends DelegatingState<AppEvents, BaseContext, AppStates, KmtInputStateMachine> {
constructor(context: KmtInputContext) {
super(createKmtInputStateMachine(context));
}
protected _eventReactions = {
switchToApp: { action: NO_OP, defaultTargetState: 'IDLE' },
};
}拡張
TemplateState<EventPayloadMapping,Context,States,EventOutputMapping>
型パラメーター
EventPayloadMapping
EventPayloadMapping
The parent machine's event mapping
Context
Context extends BaseContext
The parent machine's context
States
States extends string
The parent machine's state union
Child
Child extends HostableStateMachine
The child machine type, exposed through DelegatingState.child
EventOutputMapping
EventOutputMapping extends Partial<Record<keyof EventPayloadMapping, unknown>> = DefaultOutputMapping<EventPayloadMapping>
The parent machine's output mapping
コンストラクター
コンストラクター
new DelegatingState<
EventPayloadMapping,Context,States,Child,EventOutputMapping>(child):DelegatingState<EventPayloadMapping,Context,States,Child,EventOutputMapping>
パラメータ
child
Child
戻り値
DelegatingState<EventPayloadMapping, Context, States, Child, EventOutputMapping>
上書き
プロパティ
_defer
protected_defer:Defer<Context,EventPayloadMapping,States,EventOutputMapping>
上書き
_delay
protected_delay:Delay<Context,EventPayloadMapping,States,EventOutputMapping> |undefined=undefined
継承元
_eventGuards
protected_eventGuards:Partial<EventGuards<EventPayloadMapping,States,Context,Guard<Context>>>
定義: interface.ts:993
継承元
_eventPreconditions
protected_eventPreconditions:Partial<EventPreconditions<EventPayloadMapping,Context,Guard<Context>>>
定義: interface.ts:998
継承元
TemplateState._eventPreconditions
_eventReactions
protected_eventReactions:EventReactions<EventPayloadMapping,Context,States,EventOutputMapping>
定義: interface.ts:981
継承元
_guards
protected_guards:Guard<Context>
定義: interface.ts:992
継承元
アクセッサー
child
署名を取得する
get child():
Child
The hosted child machine, for introspection and tests.
戻り値
Child
delay
署名を取得する
get delay():
Delay<Context,EventPayloadMapping,States,EventOutputMapping> |undefined
戻り値
Delay<Context, EventPayloadMapping, States, EventOutputMapping> | undefined
継承元
eventGuards
署名を取得する
get eventGuards():
Partial<EventGuards<EventPayloadMapping,States,Context,Guard<Context>>>
戻り値
Partial<EventGuards<EventPayloadMapping, States, Context, Guard<Context>>>
継承元
eventPreconditions
署名を取得する
get eventPreconditions():
Partial<EventPreconditions<EventPayloadMapping,Context,Guard<Context>>>
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.
戻り値
Partial<EventPreconditions<EventPayloadMapping, Context, Guard<Context>>>
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.
継承元
TemplateState.eventPreconditions
eventReactions
署名を取得する
get eventReactions():
EventReactions<EventPayloadMapping,Context,States,EventOutputMapping>
戻り値
EventReactions<EventPayloadMapping, Context, States, EventOutputMapping>
継承元
guards
署名を取得する
get guards():
Guard<Context>
戻り値
Guard<Context>
継承元
handlingEvents
署名を取得する
get handlingEvents(): keyof
EventPayloadMapping[]
戻り値
keyof EventPayloadMapping[]
継承元
メソッド
beforeExit()
beforeExit(
_context,_stateMachine,_to):void
パラメータ
_context
Context
_stateMachine
StateMachine<EventPayloadMapping, Context, States, EventOutputMapping>
_to
"TERMINAL" | States
戻り値
void
上書き
handles()
handles<
K>(args,context,stateMachine):EventResult<States,Kextends keyofEventOutputMapping?EventOutputMapping[K<K>] :void>
型パラメーター
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
パラメータ
_context
Context
_stateMachine
StateMachine<EventPayloadMapping, Context, States, EventOutputMapping>
_from
"INITIAL" | States
戻り値
void