Skip to content

@ue-too/being / index / DelegatingState

抽象 クラス: DelegatingState<EventPayloadMapping, Context, States, Child, EventOutputMapping> ​

定義: delegating-state.ts:65

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.

例 ​

typescript
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>

定義: delegating-state.ts:81

パラメータ ​

child ​

Child

戻り値 ​

DelegatingState<EventPayloadMapping, Context, States, Child, EventOutputMapping>

上書き ​

TemplateState.constructor

プロパティ ​

_defer ​

protected _defer: Defer<Context, EventPayloadMapping, States, EventOutputMapping>

定義: delegating-state.ts:91

上書き ​

TemplateState._defer


_delay ​

protected _delay: Delay<Context, EventPayloadMapping, States, EventOutputMapping> | undefined = undefined

定義: interface.ts:1003

継承元 ​

TemplateState._delay


_eventGuards ​

protected _eventGuards: Partial<EventGuards<EventPayloadMapping, States, Context, Guard<Context>>>

定義: interface.ts:993

継承元 ​

TemplateState._eventGuards


_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

継承元 ​

TemplateState._eventReactions


_guards ​

protected _guards: Guard<Context>

定義: interface.ts:992

継承元 ​

TemplateState._guards

アクセッサー ​

child ​

署名を取得する ​

get child(): Child

定義: delegating-state.ts:87

The hosted child machine, for introspection and tests.

戻り値 ​

Child


delay ​

署名を取得する ​

get delay(): Delay<Context, EventPayloadMapping, States, EventOutputMapping> | undefined

定義: interface.ts:1042

戻り値 ​

Delay<Context, EventPayloadMapping, States, EventOutputMapping> | undefined

継承元 ​

TemplateState.delay


eventGuards ​

署名を取得する ​

get eventGuards(): Partial<EventGuards<EventPayloadMapping, States, Context, Guard<Context>>>

定義: interface.ts:1021

戻り値 ​

Partial<EventGuards<EventPayloadMapping, States, Context, Guard<Context>>>

継承元 ​

TemplateState.eventGuards


eventPreconditions ​

署名を取得する ​

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 ​

署名を取得する ​

get eventReactions(): EventReactions<EventPayloadMapping, Context, States, EventOutputMapping>

定義: interface.ts:1033

戻り値 ​

EventReactions<EventPayloadMapping, Context, States, EventOutputMapping>

継承元 ​

TemplateState.eventReactions


guards ​

署名を取得する ​

get guards(): Guard<Context>

定義: interface.ts:1017

戻り値 ​

Guard<Context>

継承元 ​

TemplateState.guards


handlingEvents ​

署名を取得する ​

get handlingEvents(): keyof EventPayloadMapping[]

定義: interface.ts:1011

戻り値 ​

keyof EventPayloadMapping[]

継承元 ​

TemplateState.handlingEvents

メソッド ​

beforeExit() ​

beforeExit(_context, _stateMachine, _to): void

定義: delegating-state.ts:129

パラメータ ​

_context ​

Context

_stateMachine ​

StateMachine<EventPayloadMapping, Context, States, EventOutputMapping>

_to ​

"TERMINAL" | States

戻り値 ​

void

上書き ​

TemplateState.beforeExit


handles() ​

handles<K>(args, context, stateMachine): EventResult<States, K extends keyof EventOutputMapping ? EventOutputMapping[K<K>] : void>

定義: interface.ts:1074

型パラメーター ​

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>

継承元 ​

TemplateState.handles


uponEnter() ​

uponEnter(_context, _stateMachine, _from): void

定義: delegating-state.ts:112

パラメータ ​

_context ​

Context

_stateMachine ​

StateMachine<EventPayloadMapping, Context, States, EventOutputMapping>

_from ​

"INITIAL" | States

戻り値 ​

void

上書き ​

TemplateState.uponEnter