Class HS.Controller.StateMachine
StateMachine is used for controlling the states of widgets and determining the outcome of events based on these states
Defined in: controller.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Manages the App and Modules States and the callbacks associated with them easier to manage
and also furthers the abstraction of the application as a whole.
|
Field Attributes | Field Name and Description |
---|---|
Describes the current state of the application.
|
|
Method Attributes | Method Name and Description |
---|---|
<static> |
HS.Controller.StateMachine.changeState(module, newState, data)
Changes the state of the module as well as triggers the state change callbacks for the 2 states involved
|
<static> |
HS.Controller.StateMachine.createState(module, state, cb1, cb2)
This creates a state for a specified module.
|
<static> |
HS.Controller.StateMachine.deleteModule(module)
deletes the module and all related data in it JS object.
|
<static> |
HS.Controller.StateMachine.getSecondState(module)
Get a secondary state for modules, if it exists, to allow for more advanced state management
|
<static> |
HS.Controller.StateMachine.getState(module)
gets the state of the module name passed in the first argument
|
<static> |
HS.Controller.StateMachine.registerModule(module, states, currState)
This registers a modules with the statemachine.
|
<static> |
HS.Controller.StateMachine.setSecondState(module, newState, data)
Sets the secondary state for the modules specified, with a newState and data for the callbacks initialized
|
Class Detail
HS.Controller.StateMachine()
Manages the App and Modules States and the callbacks associated with them easier to manage
and also furthers the abstraction of the application as a whole.
- Requires:
- Class
- HS.Classes.State
- HS.Classes.ActionStack
Field Detail
{String}
appState
Describes the current state of the application. Very general state.
{HS.Classes.ActionStack}
escapeStack
{Object}
modules
Method Detail
<static>
{Void}
HS.Controller.StateMachine.changeState(module, newState, data)
Changes the state of the module as well as triggers the state change callbacks for the 2 states involved
- Parameters:
- {String} module
- The module that will be changing its state
- {String} newState
- The new state that the module will be using - Must be in states array from registerModule
- {Object} data
- The module data
- Returns:
- {Void}
<static>
{Boolean}
HS.Controller.StateMachine.createState(module, state, cb1, cb2)
This creates a state for a specified module.
- Parameters:
- {String} module
- - The module that will be changing its state
- {String} state
- - The name of the state the module is in
- {Function} cb1
- - Callback for when the state starts
- {Function} cb2
- - Callback for when the state stops
- Returns:
- {Boolean} Success
<static>
{Void}
HS.Controller.StateMachine.deleteModule(module)
deletes the module and all related data in it JS object.
- Parameters:
- {String} module
- the name of the module that will be deleted
- Returns:
- {Void}
<static>
{String|Boolean}
HS.Controller.StateMachine.getSecondState(module)
Get a secondary state for modules, if it exists, to allow for more advanced state management
- Parameters:
- {String} module
- The state will come from this module if it is available
- Returns:
- {String|Boolean} returns the secondary state of the module
<static>
{String}
HS.Controller.StateMachine.getState(module)
gets the state of the module name passed in the first argument
- Parameters:
- {String} module
- The module that will be changing its state
- Returns:
- {String} returns the modules current state.
<static>
{Boolean}
HS.Controller.StateMachine.registerModule(module, states, currState)
This registers a modules with the statemachine. The statemachine begins keeping track of the
modules state and executes the callbacks associated with the changes it sees.
- Parameters:
- {String} module
- - The name of the module being registered into the system
- {Object[]} states
- - All the possible states - Array of Strings
- {String} currState
- - Current state of the module by name
- Returns:
- {Boolean} Success
<static>
{Void|Boolean}
HS.Controller.StateMachine.setSecondState(module, newState, data)
Sets the secondary state for the modules specified, with a newState and data for the callbacks initialized
- Parameters:
- {String} module
- The name of the module that will have it's secondary state changed.
- {String} newState
- This is the name of state that the
- {Object|String|Number|Array} data
- This is the name of stat
- Returns:
- {Void|Boolean} returns false incase data is missing.