Constructor
new States(owner)
Creates a new instance of the States class, ie a state machine.
Parameters:
| Name | Type | Description |
|---|---|---|
owner |
Object | The state owner. |
- Source:
Members
(readonly) selected :rune.state.State
The state that is currently selected and thus activated.
Type:
- Source:
Methods
load(states) → {undefined}
Loads a new batch from a copied list. Later changes to the caller's array
do not affect the pending or active list, and cleanup never modifies it.
State objects retain their identity; only the containing array is copied.
Replacing a pending list retains states still used by the active or new list.
Each state object may occur only once in a batch and belong to one machine.
States are reserved on load and released after cleanup. Invalid input leaves the
active and pending lists unchanged. A load requested from init() is kept
pending until the next update; the latest pending request takes precedence.
Loads from onExit() do not replace the batch currently being activated.
Parameters:
| Name | Type | Description |
|---|---|---|
states |
Array.<rune.state.State> | List of instantiated states. |
- Source:
Throws:
-
If the batch is empty, invalid, contains duplicates or uses another machine's states.
- Type
- Error
Returns:
- Type
- undefined
select(name) → {boolean}
Selects and activates a state based on its name. Aborts if onExit()
disposes or replaces the active list. Selections requested from lifecycle
callbacks are queued for the next update; the latest valid request wins.
A later direct selection or load supersedes a queued request.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of state to be selected. |
- Source:
Returns:
Whether a state could be selected without canceling the transition.
- Type
- boolean