@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:1007
繼承自
_delay
protected_delay:Delay<Context,EventPayloadMapping,ParentStates,EventOutputMapping> |undefined=undefined
定義於: interface.ts:1003
繼承自
_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
定義於: hierarchical.ts:126
存取器
delay
Getter 簽章
get delay():
Delay<Context,EventPayloadMapping,States,EventOutputMapping> |undefined
定義於: interface.ts:1042
回傳
Delay<Context, EventPayloadMapping, States, EventOutputMapping> | undefined
繼承自
eventGuards
Getter 簽章
get eventGuards():
Partial<EventGuards<EventPayloadMapping,States,Context,Guard<Context>>>
定義於: interface.ts:1021
回傳
Partial<EventGuards<EventPayloadMapping, States, Context, Guard<Context>>>
繼承自
eventPreconditions
Getter 簽章
get eventPreconditions():
Partial<EventPreconditions<EventPayloadMapping,Context,Guard<Context>>>
定義於: interface.ts:1027
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
Getter 簽章
get eventReactions():
EventReactions<EventPayloadMapping,Context,States,EventOutputMapping>
定義於: interface.ts:1033
回傳
EventReactions<EventPayloadMapping, Context, States, EventOutputMapping>
繼承自
guards
Getter 簽章
get guards():
Guard<Context>
定義於: interface.ts:1017
回傳
Guard<Context>
繼承自
handlingEvents
Getter 簽章
get handlingEvents(): keyof
EventPayloadMapping[]
定義於: interface.ts:1011
回傳
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