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 |
- Source:
Methods
-
addTransition(start, token, end)
-
Adds a transition to the state machine
Parameters:
Name Type Description startstring name of the state at the beginning of the transition tokenstring name of the token triggering the transition endstring name of the state reached at the end of the transition - Source:
-
setFinalState(string)
-
Sets the final state of the statemachine
Parameters:
Name Type Description stringstring name of the final state - Source:
-
setInitialState(string)
-
Sets the initial state of the statemachine
Parameters:
Name Type Description stringstring name of the initial state - Source:
-
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 tokenstring name of the token - Source:
-
setTransitions(obj)
-
Sets transitions from a list of transitions
Parameters:
Name Type Description objobject[] list of transitions - Source:
-
start()
-
Initialize and starts the statemachine, setting its current state to the initial state (by default, it is the departure of the first transition
- Source:
.js