States
State Hooks
Configure action components to run when a stub is in a state, when it enters a state, or when it exits a state.
See state hooks for a conceptual overview of state hooks.
Basic Usage
Properties
on_enter_state
Action components to add to any action that causes the stub to enter this state.
in_state
Action components to add to any action that runs while the stub is in this state.
on_exit_state
Action components to add to any action that causes the stub to exit this state.
Where Action components are tasks, notifications, and metrics you want to add to the action.
Configuration
State hooks can be configured in a GUI using the editor.
Similar to configuring actions, you can add tasks, notifications, and metrics to the on_enter_state
, in_state
, and on_exit_state
objects using the UI.
Example:
Result
In the above flow, the example state_hooks
have been added to the basic-state
.
Below, you can see how those tasks defined in the state_hooks
are executed as a stub transitions to and out of the basic-state
.
- When
go_to_basic
action is ran, theon_enter_hook_task
is executed.on_enter_hook_task
is executed because the stub is entering thebasic-state
.
- When
go_to_done
action is ran, bothin_state_hook_task
andon_exit_hook_task
are executed.in_state_hook_task
is executed because the stub is in thebasic-state
.on_exit_hook_task
is executed because the stub is exiting thebasic-state
and going to thedone
state.