@ue-too/being / index / CompositeState
抽象 類別: CompositeState<EventPayloadMapping, Context, ParentStates, ChildStates, EventOutputMapping>
定義於: hierarchical.ts:106
Composite state that contains a child state machine.
備註
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
};
}
}Extends
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
定義於: 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
繼承自
_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
定義於: hierarchical.ts:126
存取器
delay
Getter 簽章
get delay():
Delay<Context,EventPayloadMapping,States,EventOutputMapping> |undefined
定義於: interface.ts:884
回傳
Delay<Context, EventPayloadMapping, States, EventOutputMapping> | undefined
繼承自
eventGuards
Getter 簽章
get eventGuards():
Partial<EventGuards<EventPayloadMapping,States,Context,Guard<Context>>>
定義於: interface.ts:869
回傳
Partial<EventGuards<EventPayloadMapping, States, Context, Guard<Context>>>
繼承自
eventReactions
Getter 簽章
get eventReactions():
EventReactions<EventPayloadMapping,Context,States,EventOutputMapping>
定義於: interface.ts:875
回傳
EventReactions<EventPayloadMapping, Context, States, EventOutputMapping>
繼承自
guards
Getter 簽章
get guards():
Guard<Context>
定義於: interface.ts:865
回傳
Guard<Context>
繼承自
handlingEvents
Getter 簽章
get handlingEvents(): keyof
EventPayloadMapping[]
定義於: interface.ts:859
回傳
keyof EventPayloadMapping[]
繼承自
方法
beforeExit()
beforeExit(
context,stateMachine,to):void
定義於: hierarchical.ts:217
參數
context
Context
stateMachine
StateMachine<EventPayloadMapping, Context, ParentStates, EventOutputMapping>
to
"TERMINAL" | ParentStates
回傳
void
覆寫了
getChildStateMachine()
abstractprotectedgetChildStateMachine():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,Kextends keyofEventOutputMapping?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>
覆寫了
uponEnter()
uponEnter(
context,stateMachine,from):void
定義於: hierarchical.ts:177
參數
context
Context
stateMachine
StateMachine<EventPayloadMapping, Context, ParentStates, EventOutputMapping>
from
"INITIAL" | ParentStates
回傳
void