Skip to content

StateDefinition

Defined in: StateMachine.ts:75

One state in a StateMachine transition table.

S extends string

readonly optional enter?: (transition) => void

Defined in: StateMachine.ts:86

Called after this state becomes current.

StateTransition<NoInfer<S>> | null

void


readonly optional exit?: (transition) => void

Defined in: StateMachine.ts:88

Called before this state stops being current.

StateTransition<NoInfer<S>>

void


readonly optional for?: number | (() => number)

Defined in: StateMachine.ts:82

Seconds before the machine enters next. A function is called each time the state is entered, and must return a finite number above 0.


readonly optional fromAny?: boolean

Defined in: StateMachine.ts:102

Whether every other state may enter this one without declaring it in to. For the handful of states a whole machine falls into, such as hit or die. It adds no edge from this state to itself.


readonly optional next?: NoInfer<S>

Defined in: StateMachine.ts:84

State entered when for elapses. Must be one this state can reach.


readonly optional start?: NoInfer<S>

Defined in: StateMachine.ts:96

Child entered with this state. Required when states is declared.


readonly optional states?: Readonly<{ [K in string]?: ChildStateDefinition<S> }>

Defined in: StateMachine.ts:94

Phases of this state, named in the same union as every other state. The machine is in exactly one of them while this state is current. Nesting is one level deep.


readonly optional to?: readonly NoInfer<S>[]

Defined in: StateMachine.ts:77

States reachable from this one with StateMachine.go.

Coding agents: fetch https://yage.dev/llms.txt first and prefer the Markdown references it links over these HTML pages. This page's Markdown counterpart is /llms/packages/core.md.