Skip to content

@ue-too/being-portable / PortableMachine

Interface: PortableMachine ​

Defined in: being-portable/src/api-types.ts:63

A loaded machine: an ordinary being state machine plus its definition, snapshot and restore.

Extends ​

Properties ​

context ​

readonly context: PortableContext

Defined in: being-portable/src/api-types.ts:71

Read-only access to the machine's live context object. Optional so existing StateMachine implementations remain valid; TemplateStateMachine always provides it. Intended for tooling/introspection (e.g. visualizers evaluating guards against the current context) — mutate state through events, not through this reference.

Overrides ​

StateMachine.context


currentState ​

currentState: string

Defined in: being/dist/interface.d.ts:220

Inherited from ​

StateMachine.currentState


definition ​

readonly definition: MachineDefinition

Defined in: being-portable/src/api-types.ts:70

The upgraded, normalized document, frozen.


possibleStates ​

possibleStates: string[]

Defined in: being/dist/interface.d.ts:199

Inherited from ​

StateMachine.possibleStates


states ​

states: Record<States, State<EventPayloadMapping, Context, string extends States ? string : States, EventOutputMapping>>

Defined in: being/dist/interface.d.ts:191

Inherited from ​

StateMachine.states

Methods ​

happens() ​

Call Signature ​

happens<K>(...args): EventResult<string, K extends never ? PortableOutputs[K<K>] : void>

Defined in: being/dist/interface.d.ts:188

Type Parameters ​
K ​

K extends never

Parameters ​
args ​

...EventArgs<PortableEvents, K>

Returns ​

EventResult<string, K extends never ? PortableOutputs[K<K>] : void>

Inherited from ​

StateMachine.happens

Call Signature ​

happens<K>(...args): EventResult<string, unknown>

Defined in: being/dist/interface.d.ts:189

Type Parameters ​
K ​

K extends string

Parameters ​
args ​

...EventArgs<PortableEvents, K>

Returns ​

EventResult<string, unknown>

Inherited from ​

StateMachine.happens


onEventResult()? ​

optional onEventResult(callback): void | () => void

Defined in: being/dist/interface.d.ts:216

Subscribe to every event result. Optional so existing StateMachine implementations remain valid; TemplateStateMachine always provides it. Returns a disposer on implementations that support one. Disposing during a dispatch takes effect starting with the next dispatch, not the one in progress — see EventResultCallback for the exact snapshot-iteration semantics.

Parameters ​

callback ​

EventResultCallback<PortableEvents, PortableContext, string>

Returns ​

void | () => void

Inherited from ​

StateMachine.onEventResult


onHappens() ​

onHappens(callback): void | () => void

Defined in: being/dist/interface.d.ts:207

Subscribe to every happens() call, before the state handles it. Returns a disposer on implementations that support one. Disposing during a dispatch takes effect starting with the next dispatch, not the one in progress — see EventResultCallback for the exact snapshot-iteration semantics.

Parameters ​

callback ​

(args, context) => void

Returns ​

void | () => void

Inherited from ​

StateMachine.onHappens


onStateChange() ​

onStateChange(callback): void | () => void

Defined in: being/dist/interface.d.ts:198

Subscribe to state changes. Returns a disposer on implementations that support one. Disposing during a dispatch takes effect starting with the next dispatch, not the one in progress — see EventResultCallback for the exact snapshot-iteration semantics.

Parameters ​

callback ​

StateChangeCallback<string>

Returns ​

void | () => void

Inherited from ​

StateMachine.onStateChange


reset() ​

reset(): void

Defined in: being/dist/interface.d.ts:217

Returns ​

void

Inherited from ​

StateMachine.reset


restore() ​

restore(snapshot, options?): RestoreResult

Defined in: being-portable/src/api-types.ts:74

Parameters ​

snapshot ​

unknown

options? ​
mode? ​

RestoreMode

Returns ​

RestoreResult


setContext() ​

setContext(context): void

Defined in: being/dist/interface.d.ts:190

Parameters ​

context ​

PortableContext

Returns ​

void

Inherited from ​

StateMachine.setContext


snapshot() ​

snapshot(): MachineSnapshot

Defined in: being-portable/src/api-types.ts:73

Throws while the machine is handling an event.

Returns ​

MachineSnapshot


start() ​

start(): void

Defined in: being/dist/interface.d.ts:218

Returns ​

void

Inherited from ​

StateMachine.start


switchTo() ​

switchTo(state): void

Defined in: being/dist/interface.d.ts:178

Parameters ​

state ​

string

Returns ​

void

Inherited from ​

StateMachine.switchTo


wrapup() ​

wrapup(): void

Defined in: being/dist/interface.d.ts:219

Returns ​

void

Inherited from ​

StateMachine.wrapup