Class: StateHolder

apy.helpers. StateHolder


new StateHolder(states, initialState)

Keep state among known ones

Parameters:
Name Type Description
states Object

An Object representing states

initialState string

A state picked from states

Example
var states = {
    READ: 'READ',
    ERROR: 'ERROR',
    CREATE: 'CREATE',
    UPDATE: 'UPDATE',
    DELETE: 'DELETE'
};
var initialState = states.READ;
var stateHolder = new StateHolder(initialState, states);

console.log(stateHolder.$current === states.READ); // true
stateHolder.set(states.CREATE)
console.log(stateHolder.$current === states.CREATE); // true

Methods


<static> StateHolder#load()

Load all given states into itself All states are upper-cased before being set.

Returns:

this

Type
apy.helpers.StateHolder

<static> StateHolder#set(state)

Set a state picked from states reference

Parameters:
Name Type Description
state string

A state picked from states

Returns:

this

Type
apy.helpers.StateHolder