new FiniteStateMachine(app, transitionTable, stateFetcher, stateUpdater)
Finite State Machine
- Source:
Parameters:
Name | Type | Description |
---|---|---|
app |
*
|
Application instance, can be null if not needed |
transitionTable |
object
|
{ state: { action: { desc, when, target, before, after } } } Action rule:
|
stateFetcher |
function
|
(app, context, fetcherOpts) => state |
stateUpdater |
function
|
(app, context, payload, targetState, updaterOpts) => [actuallyUpdated, updateResult] |
Members
(static) ifAll
If all of the conditions in the array are met, return OK, otherwise fail with a reason.
- Source:
(static) ifAny
If any of the conditions in the array is met, return OK, otherwise fail with a reason.
- Source:
Methods
(async) doAction_(action, context, payload, fetcherOpts, updaterOpts)
Perform the specified action.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
action |
String
|
|
context |
*
|
|
payload |
*
|
|
fetcherOpts |
*
|
|
updaterOpts |
*
|
(async) getAllowedActions_(context, withDisallowedReason)
Get a list of allowed actions based on the current state.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
context |
*
|
|
withDisallowedReason |
boolean
|