@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
定義: interface.ts:855
継承元
_delay
protected_delay:Delay<Context,EventPayloadMapping,ParentStates,EventOutputMapping> |undefined=undefined
定義: interface.ts:851
継承元
_eventGuards
protected_eventGuards:Partial<EventGuards<EventPayloadMapping,States,Context,Guard<Context>>>
定義: interface.ts:846
継承元
_eventReactions
protected_eventReactions:EventReactions<EventPayloadMapping,Context,States,EventOutputMapping>
定義: interface.ts:834
継承元
_guards
protected_guards:Guard<Context>
定義: interface.ts:845
継承元
_historyState
protected_historyState:ChildStates|null=null
アクセッサー
delay
署名を取得する
get delay():
Delay<Context,EventPayloadMapping,States,EventOutputMapping> |undefined
定義: interface.ts:884
戻り値
Delay<Context, EventPayloadMapping, States, EventOutputMapping> | undefined
継承元
eventGuards
署名を取得する
get eventGuards():
Partial<EventGuards<EventPayloadMapping,States,Context,Guard<Context>>>
定義: interface.ts:869
戻り値
Partial<EventGuards<EventPayloadMapping, States, Context, Guard<Context>>>
継承元
eventReactions
署名を取得する
get eventReactions():
EventReactions<EventPayloadMapping,Context,States,EventOutputMapping>
定義: interface.ts:875
戻り値
EventReactions<EventPayloadMapping, Context, States, EventOutputMapping>
継承元
guards
署名を取得する
get guards():
Guard<Context>
定義: interface.ts:865
戻り値
Guard<Context>
継承元
handlingEvents
署名を取得する
get handlingEvents(): keyof
EventPayloadMapping[]
定義: interface.ts:859
戻り値
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