Skip to main content

defineStateName

defineStateName<Context, Protocol>(state, name): void

Assigns a stable display name to a single state class.

Minifiers rewrite Class.name in production browser bundles; explicit registration keeps Properties.currentStateName, trace output, and error messages readable everywhere.

Type Parameters

Context

Context

Domain context type

Protocol

Protocol extends { } | undefined

Vocabulary interface

Parameters

state

StateClass<Context, Protocol>

State class constructor to tag

name

string

Non-empty display string used in traces and errors (not required to match Class.name)

Returns

void

Remarks

Stored as a non-enumerable own property — never inherited by subclasses from the prototype chain. registerStateNames is preferred when every state is a named export from one module.

Example

class Door extends TopState {}
defineStateName(Door, 'Door');