Skip to main content

Properties

Read-only snapshot of runtime metadata shared by client handles and active handlers.

Exposed on State (inside handlers as this.hsm properties and forwarded getters on TopState) and on Hsm (external client code). Values reflect the current dispatch when read from within an event handler; outside handlers, eventName and eventPayload are empty.

Extended by

Type Parameters

Context

Context

Protocol

Protocol extends { } | undefined

Properties

currentState

readonly currentState: StateClass<Context, Protocol>

Constructor (Function) of the leaf state class currently executing.

Compare with topState, which is always the root composite passed to makeHsm. After a transition, this updates to the new leaf's constructor.


currentStateName

readonly currentStateName: string

Human-readable name of currentState.

Sourced from defineStateName / registerStateNames when registered; otherwise Class.name (unreliable under minification — register names in browser builds).


topState

readonly topState: StateClass<Context, Protocol>

Constructor of the root state class supplied to makeHsm.

Constant for the lifetime of the instance unless you replace the entire machine.


topStateName

readonly topStateName: string

Display name of topState (same naming rules as currentStateName).


ctxTypeName

readonly ctxTypeName: string

Runtime label derived from ctx constructor name, used as the first segment of traceHeader in verbose traces.


traceHeader

readonly traceHeader: string

Prefix for nested trace domains, built from internal dispatch stack frames.

Empty at the top level; grows like domain|subdomain| during nested operations. Handlers rarely need to read this directly — it is prepended automatically by the default TraceWriter.


eventName

readonly eventName: string

Name of the event or service currently being dispatched.

Matches the string passed to Base.post, Hsm.call, or State.postNow. Empty string when no handler is running.


eventPayload

readonly eventPayload: any[]

Arguments passed with the current dispatch, excluding injected resolve / reject for Hsm.call services.

Empty array when idle. Typed as any[] at runtime; correlate with EventPayload / ServiceRequest at compile time on the client.


traceLevel

traceLevel: TraceLevel

Active trace verbosity; changing this swaps dispatch tracing behavior immediately.

See

TraceLevel


traceWriter

traceWriter: TraceWriter

Destination for runtime and handler-initiated trace lines.

Replaceable at any time (e.g. swap in a test double before post/call).


dispatchErrorCallback

dispatchErrorCallback: DispatchErrorCallback<Context, Protocol>

Last-resort error hook when StateEvents.onError / StateEvents.onUnhandled do not recover.

See

DispatchErrorCallback