Actors
When you run a statechart, it becomes an actor: a running process that can receive messages, send messages and change its behavior based on the messages it receives, which can cause effects outside of the actor.
An invoked actor is an actor that can execute its own actions and communicate with the machine. These invoked actors are started in a state and stopped when the state is exited.
Invoked actors are are labeled on their invoking state with “Invoke /” followed by the actor’s source name and ID.
You can invoke multiple actors on a single state. Top-level final states cannot have invoked actors.
View this machine in the Stately Studio.
In the video player above, the startVideo actor is invoked when the video player is in the Opened state.
Invoke actors on a state​
First, select the state where you want to invoke an actor.
On the canvas​
- Select the state where you want to invoke an actor.
- Use the plus icon button to open the edit menu.
- Choose Invoked actor from the menu to add an invoked actor block to the event.
- Write your actor’s source in the invoked actors’s text input.
Add actor source logic and ID​
- Use the edit icon button to open the Invoked actor panel.
- Enter the actor’s source logic in the Source logic text input.
- Enter the actor’s ID in the Actor ID text input.
Using the event details panel​
- Select the state where you want to invoke an actor.
- Open the state Details panel from the right tool menu.
- Use the + Effect button to open the effects menu, and choose Add invoked actor.
- Use the edit icon button to open the Invoked actor panel.
- Enter the actor’s source logic in the Source logic text input.
- Enter the actor’s ID in the Actor ID text input.