new StateMachine(obj)
Describes a statemachine
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
obj |
object | an object describing a state machine. If obj is empty then the statemachine is empty
Properties
|
Methods
addTransition(start, token, end)
Adds a transition to the state machine
Parameters:
| Name | Type | Description |
|---|---|---|
start |
string | name of the state at the beginning of the transition |
token |
string | name of the token triggering the transition |
end |
string | name of the state reached at the end of the transition |
setFinalState(string)
Sets the final state of the statemachine
Parameters:
| Name | Type | Description |
|---|---|---|
string |
string | name of the final state |
setInitialState(string)
Sets the initial state of the statemachine
Parameters:
| Name | Type | Description |
|---|---|---|
string |
string | name of the initial state |
setToken(token)
Gives a token to the statemachine. According to its list of transitions
and the current state, it may trigger a transition
Parameters:
| Name | Type | Description |
|---|---|---|
token |
string | name of the token |
setTransitions(obj)
Sets transitions from a list of transitions
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Array.<object> | list of transitions |
start()
Initialize and starts the statemachine, setting its current state to
the initial state (by default, it is the departure of the first transition
.js