Class: StateMachine

StateMachine

Classes

State

Members

(nullable) currentState :string

Type:
  • string

(nullable) globalOnEnter :function

Type:
  • function

(nullable) globalOnExit :function

Type:
  • function

(nullable) initialState :string

Type:
  • string

numberOfStates :number

Type:
  • number

(non-null) states :Object.<string, up.api.common.StateMachine.State>

Type:

Methods

addState(stateName, stateDescription) → {boolean}

Parameters:
Name Type Description
stateName string The name of the state to add.
stateDescription Object The description of the state, with onEnter & onExit functions.
Returns:
True. Always true.
Type
boolean

createState(stateName) → (non-null) {up.api.common.StateMachine.State}

Parameters:
Name Type Description
stateName string The name of the state.
Returns:
The new state.
Type
up.api.common.StateMachine.State

getCurrentState() → (nullable) {string}

Returns:
The name of the current state, or null if the state machine hasn't been started.
Type
string

getStates() → (non-null) {Object.<string, up.api.common.StateMachine.State>}

Returns:
The states.
Type
Object.<string, up.api.common.StateMachine.State>

gotoState(stateName)

Parameters:
Name Type Description
stateName string The name of the state to go to.

start()

Start the state machine.