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 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 - Source:
-
setFinalState(string)
-
Sets the final state of the statemachine
Parameters:
Name Type Description string
string name of the final state - Source:
-
setInitialState(string)
-
Sets the initial state of the statemachine
Parameters:
Name Type Description string
string 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 token
string name of the token - Source:
-
setTransitions(obj)
-
Sets transitions from a list of transitions
Parameters:
Name Type Description obj
object[] 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: