StateMachine.Guard (state_machine v0.1.8)
Guards are functions that help to decide whether it's allowed to proceed with Event or Transition. They might serve different purposes:
- Preventing a state machine from getting into a state unless some criteria met
- Creating event with multiple target states with a single source state
Guards should not have any side-effects, cause they are getting run no matter if transition is successful or not, and also to determine the list of possible events for a certain state.
Summary
Functions
Check runs guards associated with given Event or Transition and returns true if all passed. First argument of the guard is a model, second argument is the context.
Unifies if
and unless
guards into a single stream of guards.
Types
Functions
@spec check( StateMachine.Context.t(m), StateMachine.Event.t(m) | StateMachine.Transition.t(m) ) :: boolean()
Check runs guards associated with given Event or Transition and returns true if all passed. First argument of the guard is a model, second argument is the context.
Unifies if
and unless
guards into a single stream of guards.