state_machine v0.1.1 StateMachine.Guard
Guards are functions bound to Events and Transitions that help to decide whether it's allowed to proceed. They might serve different purposes:
- Protecting state maching from getting into some state unless some criteria met
- Creating event with multiple target states
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.
Link to this section Summary
Functions
Check runs guards associated with given Event or Transition and returns true if all passed, guard returning. Second argument is the context, that gets passed on to each guard.
Link to this section Types
Link to this type
t(model)
Link to this section Functions
Link to this function
check(ctx, map)
check(ctx, map)
check(
StateMachine.Context.t(m),
StateMachine.Event.t(m) | StateMachine.Transition.t(m)
) :: boolean()
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, guard returning. Second argument is the context, that gets passed on to each guard.
Link to this function