You can specify a single event or multiple events. Using a single eventįor example, a workflow with the following on value will run when a push is made to any branch in the workflow's repository: on: push Using multiple events
![actions for actors actions for actors](https://static0.srcdn.com/wordpress/wp-content/uploads/2020/05/Overlooked-Action-Stars.jpg)
These options are described in the following sections. You can also restrict the execution of a workflow to only occur for specific files, tags, or branch changes. You can define single or multiple events that can a trigger workflow, or set a time schedule. For a list of available events, see " Events that trigger workflows." To automatically trigger a workflow, use on to define which events can cause the workflow to run. If you omit name, GitHub sets it to the workflow file path relative to the root of the repository. GitHub displays the names of your workflows on your repository's actions page. github/workflows directory of your repository. If you're new to YAML and want to learn more, see " Learn YAML in Y minutes." getSnapshot() on the child machine refĪctions : sendParent ( 'REMOTE.ONLINE' ) } } } } } ) const parentMachine = createMachine ( as an option to spawn(.Workflow files use YAML syntax, and must have either a. sync - (optional) true if this machine should be automatically subscribed to the spawned child machine's state, the state can be retrieved from.autoForward - (optional) true if all events sent to this machine should also be sent (or forwarded) to the invoked child ( false by default).This should be unique for all spawned actors and invoked services.Īlternatively spawn accepts an options object as the second argument which may contain the following options: name (optional) - a string uniquely identifying the actor.entity - the (reactive) value or machine that represents the behavior of the actor.The spawn(.) function creates an actor reference by providing 1 or 2 arguments: In an assign(.) action, create a new actor reference with spawn(.).Import the spawn function from 'xstate'.Just as in Actor-model-based languages like Akka (opens new window) or Erlang (opens new window), actors are spawned and referenced in context (as the result of an assign(.) action). For observables, the latest emitted value is emitted.For promises, the resolved value (or undefined if unfulfilled) is emitted.For services, the current state is emitted.Invoked observables are actors whose emitted values represent events to be sent back to the parent.Īn actor's emitted value is the value that subscribers receive in the actor's.Invoked machines are actors that can send events to the parent ( sendParent(.) action) or other actors it has references to ( send(.) action), receive events, act on them (state transitions and actions), spawn new actors ( spawn(.) function), and stop actors.Invoked callbacks are actors that can send events to the parent (first callback argument), receive events (second onReceive argument), and act on them.Invoked promises are actors that ignore any received events and send at most one event back to the parent.subscribe(.) method for actors that are Observable (opens new window).Īll the existing invoked service patterns fit this interface: stop() method which stops the actor and performs any necessary cleanup getSnapshot() method, which synchronously returns the actor's last emitted value. send(.) method, which is used to send events to this actor An id property, which uniquely identifies the actor in the local system.They can be stopped at any time (via a stop(.) action)Īn actor (as implemented in XState) has an interface of:.They can be spawned at any time (via spawn(.) inside of an assign(.) action).Spawned actors have two major differences from invoked actors: The next actions to be executed (potentially newly spawned actors or messages sent to other actors)Īctors can be spawned or invoked.The next value and context (an actor's local state).Remember: when a state machine transitions due to an event, the next state contains: State machines and statecharts work very well with the actor model, as they are event-based models of behavior and logic. The actor's local state may change (determined by its behavior).A finite number of new actors can be created (or spawned).A finite number of messages can be sent to other actors.When an actor receives an event, three things can happen:
![actions for actors actions for actors](https://i.pinimg.com/originals/7e/9a/68/7e9a684d079287d618bea4f452e4ad93.jpg)
An actor's local state is private, unless it wishes to share it with another actor, by sending it as an event. Actors communicate by sending messages (events) to each other.
![actions for actors actions for actors](https://i.ytimg.com/vi/7PcQc-SL0MU/maxresdefault.jpg)
The Actor model (opens new window) is a mathematical model of message-based computation that simplifies how multiple "entities" (or "actors") communicate with each other.