You can use stateMachineTrigger in EAL to make an object reevaluate the guard conditions on transitions without named triggers from its current state.
Purpose
stateMachineTrigger triggers state transitions that have no trigger defined for the object's state machines. It evaluates the available transition guards from the object's current state and performs a transition when a guard permits it.
Use it when the route through a state machine is defined by guard conditions rather than by manually invoking named triggers.
Syntax
Object.stateMachineTrigger
How it works
When you invoke stateMachineTrigger on an object, its state machine checks transitions that can leave the current state and that have no named trigger. Each transition's guard determines whether that transition is available.
If a guard becomes true because the object's data has changed, invoke stateMachineTrigger to have the state machine check whether it can move forward. The operator does not define the guard or change the object's data; it causes the state machine to reevaluate the guards.
Use it in an EAL action
- Define the state-machine transitions that should be automatic, with no named trigger.
- Put the condition for each route in its transition guard.
- In the EAL action that changes the data used by those guards, invoke
stateMachineTriggeron the affected object. - The object evaluates the guards from its current state and transitions if a transition is permitted.
For example, an action can evaluate the guards for the current object:
self.stateMachineTrigger
This tells self to check whether it can move from its current state based on its current data and the transition guards.
Example: guard-driven path
Consider an object whose current state has two outgoing transitions without named triggers:
| Transition | Guard result | Outcome after self.stateMachineTrigger
|
|---|---|---|
| Current state to Route A | The Route A guard is true | The object can transition to Route A. |
| Current state to Route B | The Route B guard is true | The object can transition to Route B. |
| Any outgoing transition | No guard permits a transition | The object remains in its current state. |
Use this pattern when the state machine should follow the path selected by its guards. If you need an action to select a particular transition by name, use a named trigger instead of relying on guard reevaluation.
Notes
- The operator applies to the object on which you invoke it, such as
self. - It evaluates transitions from the object's current state.
- Only transitions without triggers are described by this operator.
- The result depends on the guards and the object's data at the time of evaluation.
