1. States
  2. State Hooks

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.

TIP

See state hooks for a conceptual overview of state hooks.

Basic Usage

loading...

Properties

on_enter_state

optional
object

Action components to add to any action that causes the stub to enter this state.


in_state

optional
object

Action components to add to any action that runs while the stub is in this state.


on_exit_state

optional
object

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.

UI Config

Example:

loading...

Result

Example Flow

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.

Example Stub

  • When go_to_basic action is ran, the on_enter_hook_task is executed.
    • on_enter_hook_task is executed because the stub is entering the basic-state.
  • When go_to_done action is ran, both in_state_hook_task and on_exit_hook_task are executed.
    • in_state_hook_task is executed because the stub is in the basic-state.
    • on_exit_hook_task is executed because the stub is exiting the basic-state and going to the done state.