StateMachine class
Finite State Machine implementation.
It can be in one of States defined by State. State transitions are triggered by Events of type Event.
Properties
-
complete
→ Future<
void> -
Call this method to ensure that your StateMachine has completed
processing all Events.
The StateMachine is considered to be in an indeterminate state
until this method completes.
If can submit additional events after calling complete but
you must then call complete again to ensure the new
events have been processed.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
history
→ List<
Tracker> -
If production mode is off then we track
each transition to aid with debugging.
The first entry in the history will be the initial
state.
In production mode the list is empty.
final
- initialEvent → InitialEvent
-
final
- initialState → Type?
-
no setter
- initialStateLabel → String?
-
no setter
-
initialTransition
→ TransitionDefinition<
InitialEvent> -
no setter
- production → bool?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stateOfMind → StateOfMind
-
no setter
-
stream
→ Stream<
StateOfMind> -
Returns Stream of
StateOfMind
which reflects the StateMachines complete state each time a state change occurs.no setter -
topStateDefinitions
→ List<
StateDefinition< State> > -
no setter
-
virtualRoot
→ StateDefinition<
VirtualRoot> -
The base of the state tree.
no setter
-
waitUntilQuiescent
→ Future<
void> -
waits until all events have been processed.
@visibleForTesting
no setter
Methods
-
analyse(
) → bool - Checks that every leaf in the StateMachine can be reached. Use this method during development to ensure your StateMachine is in a consistent state.
-
applyEvent<
E extends Event> (E event) → void -
Call this method with an
event
to transition to a new State. -
export(
String path) → ExportedPages - Exports the StateMachine to dot notation which can then be used by xdot to display a diagram of the state machine.
-
isInState<
S extends State> () → Future< bool> - Returns true if the StateMachine is in the given state.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
traverseTree(
void listener(StateDefinition< State> stateDefinition, List<TransitionDefinition< transitionDefinitions), {bool includeInherited = true}) → Future<Event> >void> - Traverses the State tree calling listener for each state and each statically defined transition. This method is intended to help you debug your StateMachine.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
create(
BuildGraph buildGraph, {bool production = false}) → Future< StateMachine> - Creates a statemachine using a builder pattern.