@ue-too/being / index / CompositeState
抽象 クラス: CompositeState<EventPayloadMapping, Context, ParentStates, ChildStates, EventOutputMapping>
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.
例
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>
継承元
プロパティ
_childStateMachineConfig
protected_childStateMachineConfig:ChildStateMachineConfig<EventPayloadMapping,Context,ChildStates,EventOutputMapping> |null=null
_context
protected_context:Context|null=null
_defer
protected_defer:Defer<Context,EventPayloadMapping,ParentStates,EventOutputMapping> |undefined=undefined
継承元
_delay
protected_delay:Delay<Context,EventPayloadMapping,ParentStates,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
継承元
_historyState
protected_historyState:ChildStates|null=null
アクセッサー
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, ParentStates, EventOutputMapping>
to
"TERMINAL" | ParentStates
戻り値
void
上書き
getChildStateMachine()
abstractprotectedgetChildStateMachine():ChildStateMachineConfig<EventPayloadMapping,Context,ChildStates,EventOutputMapping>
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
Gets the current child state, or null if no child state machine is active.
戻り値
ChildStates | null
getStatePath()
getStatePath(
parentState):HierarchicalStatePath<ParentStates,ChildStates>
Gets the full hierarchical path of the current state.
パラメータ
parentState
ParentStates
戻り値
HierarchicalStatePath<ParentStates, ChildStates>
handles()
handles<
K>(args,context,stateMachine):EventResult<ParentStates,Kextends keyofEventOutputMapping?EventOutputMapping[K<K>] :void>
型パラメーター
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>
上書き
uponEnter()
uponEnter(
context,stateMachine,from):void
パラメータ
context
Context
stateMachine
StateMachine<EventPayloadMapping, Context, ParentStates, EventOutputMapping>
from
"INITIAL" | ParentStates
戻り値
void