Interface: StateContainerInterface

StateContainerInterface

Class factory interface for manipulating a collection of AbstractState.

Methods

(static) Mixin(BaseClassopt) → {Class}

Creates a class that implements StateContainerInterface and extends
a specified base class.

Parameters:
Name Type Attributes Default Description
BaseClass Class <optional>
class{}

The class to extend.

Returns:

A class that extends BaseClass and implements StateContainerInterface.

Type
Class

addState(state) → {string}

Add a new state to be controlled by the container. States are stored keyed
by their name property, which must be unique. If it isn't, a number will
be added or incremented until a unique key is generated.

Parameters:
Name Type Description
state AbstractState

State to add to the container.

Returns:
  • Unique name of the state.
Type
string

discardStates()

Discards all states.

getState(name) → {AbstractState}

Return the state with the given name.

Parameters:
Name Type Description
name string

Name of the state.

Returns:
Type
AbstractState

getStateNames()

Gets an array of the names of all states in the container.

removeState(name) → {boolean}

Removes a state with the given name from the container.

Parameters:
Name Type Description
name string

Name of the state to remove.

Returns:
  • Whether or not a state was removed.
Type
boolean

renameState(currentName, newName) → {string}

Renames a state with the given name in the container. Name must be unique
to the container, if it isn't the name will be incremented until it is unique.

Parameters:
Name Type Description
currentName string

Name of the state to rename.

newName string

Name to update the state with.

Returns:
  • Updated name for the state.
Type
string