Emits a StatelySuccess on all successful state changes.
machine.onAny$.subscribe(console.log)
// ==> { from: 'SomeState', to: 'AnotherState', context: { anyProps: 'any values' } }
Emits a StatelyError on all StatelyErrorType.
machine.onAnyError$.subscribe(console.error)
// ==> { from: 'SomeState', to: 'AnotherState', type: 'ANY_STATELY_ERROR_TYPE' }
The current state of the machine.
machine.state
// => 'SomeState'
Updates the machine to the new state and optional context.
Emits a StatelySuccess on a successful transition.
Emits a SAME_STATE error if you try to transition to the
active state, or a NO_TRANSITION error if you try to transition to a state
without a valid transition.
machine.go(States.AnotherState, { foo: foo + 1 })
Optional context: Partial<C>Emits a StatelySuccess only for the given state.
machine.on$(States.AnotherState).subscribe(console.log)
// ==> { from: 'SomeState', to: 'AnotherState', context: { anyProps: 'any values' } }
Emits a StatelyError only for the given StatelyErrorType.
machine.onError$('SPECIFIC_STATELY_ERROR_TYPE').subscribe(console.error)
// ==> { from: 'SomeState', to: 'AnotherState', type: 'SPECIFIC_STATELY_ERROR_TYPE' }
Declare all valid transitions for the machine.
Emits an EMPTY_TRANSITIONS error on go if you forget to set
the transitions.
machine.transitions([
{ from: [States.SomeState], to: [States.AnotherState] },
{ from: [States.AnotherState], to: Object.values(States) }
])
Generated using TypeDoc
The current context of the machine.
Example