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ā
- Select the state you want to invoke an actor.
- Open theĀ State detailsĀ panel from the right tool menu.
- Use theĀ +Ā plus icon alongside theĀ Invoked actorsĀ to add a new action.
- Add the source for the actor using theĀ srcĀ textĀ input.
- Add the ID for the actor using theĀ IDĀ text input.
- Save the invoked actor using theĀ SaveĀ button.