Transitions and events
A machine moves from state to state through transitions. Transitions are caused by events; when an event happens, the machine transitions to the next state.
Transitions are “deterministic”; each combination of state and event always points to the same next state.
The arrows are transitions, and the rounded rectangles on the arrow’s lines are events. Each transition has a source state which comes before the transition, and a target state, which comes after the transition. The transition’s arrow starts from the source state and points to the target state.
View this machine in the Stately Studio.
In the video player machine above, the events are PLAY and PAUSE. The Play event transitions from the Paused state to the Playing state. The Pause event transitions from the Playing state to the Paused state.
Add a transition and event
- Select an existing state.
- Drag from the handles on the left, right and bottom sides of the selected state, and release to create a connecting transition, event and new state.
Change the source and target states for a transition or event
First select the transition or event you want to change. Then…
Using the Transition details panel
- Select the transition or event you wish to change.
- Open the Transition details panel from the right tool menu.
- Choose a new source state from the Source dropdown options.
- Choose a new target state from the Target dropdown options.
Dragging the transition handles
- Select the transition or event you want to change.
- Drag the transition’s handle connected to the source state to connect it to a new source state.
- Drag the transition’s handle connected to the target state to connect it to a new target state.
Switch the source and target states for a transition or event
- Select the transition or event.
- Right-click the state to bring up the quick actions menu.
- Choose Switch source and target from the quick actions menu.