Skip to content

ChildLink

Defined in: types.ts:1157

Adapter that wraps either an Fsm or BehavioralFsm child, presenting a uniform API for parent-initiated delegation and, through subscribe, for the child’s events with the client already resolved.

instance: MachinaInstance

Defined in: types.ts:1204

The raw Fsm or BehavioralFsm instance this ChildLink wraps. Exposed for inspection tooling (machina-inspect) — allows external tools to introspect child graph structure without reaching through private fields.

canHandle(client, inputName): boolean

Defined in: types.ts:1159

Check if the child’s current state can handle this input

object

string

boolean


compositeState(client): string

Defined in: types.ts:1171

The child FSM’s compositeState for the given client

object

string


dehydrate(client, isOnActivePath): ClientSnapshot | undefined

Defined in: types.ts:1188

Snapshot everything this child tracks for client, recursing into its own children. undefined when the child has never seen this client. Throws for Fsm children that are on the active path — an Fsm owns its own context, so there’s nothing per-client to snapshot. isOnActivePath is threaded down from the true root’s dehydrate() call: it’s false whenever ANY ancestor declaring state didn’t match its own parent’s active state, so a nested BehavioralFsm child correctly treats every one of its own Fsm children as off-path once the child itself is off-path, rather than recomputing reachability from its own (possibly dormant) state alone.

object

boolean

ClientSnapshot | undefined


dispose(): void

Defined in: types.ts:1197

Dispose the child FSM

void


handle(client, inputName, …args): void

Defined in: types.ts:1161

Dispatch the input to the child

object

string

…unknown[]

void


planRehydrate(client, snapshot): (() => void)[]

Defined in: types.ts:1195

Validates snapshot against this child’s state graph (recursing into its own children) and returns write thunks to run only once the ENTIRE tree validates — nothing is written here. Throws for Fsm children, matching dehydrate().

object

ClientSnapshot

(() => void)[]


rehydrate(client, compositeState): void

Defined in: types.ts:1176

Silently place client at the given composite state within the child hierarchy. Throws for Fsm children (no per-client state to rehydrate).

object

string

void


reset(client): void

Defined in: types.ts:1163

Reset the child to its initialState

object

void


subscribe(listener): object

Defined in: types.ts:1169

Open one wildcard subscription on the child and route every event to the listener with its client resolved. One subscription per call: the parent calls this once per distinct child.

ChildListener

object

off(): void

void