States

States - The state manager. You can create multiple States instances in your application logic, e.g. for dealing with sub-states etc.

Constructor

new States(appInstance)

Constructor

Parameters:
NameTypeDescription
appInstanceApp

Instance of app

Methods

add(…stateClasses) → {boolean}

Add state class

Parameters:
NameTypeAttributesDescription
stateClassesDefaultBaseState<repeatable>

State class to be added.

Throws:
  • Throws an error when adding state is not possible
Type
Error
Returns:
  • Returns wheter or not adding was successful
Type: 
boolean

create(stateId, routeParams) → {null}

Create an instance of given state id

Parameters:
NameTypeDescription
stateIdstring

The state id to be instantiated

routeParamsRouteParams

Current RouteParams

Returns:
Type: 
null

exists(stateId) → {boolean}

Checks if given stateId already exists.

Parameters:
NameTypeDescription
stateIdstring
Returns:
Type: 
boolean

setStateNotFoundClass(notFoundClass)

Set the StateNotFound class

Parameters:
NameTypeDescription
notFoundClassState

State class used in case when a state is not found

Throws:
  • Thrown when provided param is not of type State
Type
Error

(async) switchTo(newState) → {Promise.<boolean>}

Switch to given state

Parameters:
NameTypeDescription
newStateDefaultBaseState

Instance of state to switch to

Throws:
  • Throws an error if given state cannot be entered or if enter() function throws an error.
Type
Error
Returns:
Type: 
Promise.<boolean>