Actor <TLogic>
Implements
- ActorRef<SnapshotFrom<TLogic>, EventFromLogic<TLogic>>
Index
Constructors
constructor
Creates a new actor instance for the given logic with the provided options, if any.
Type parameters
- TLogic: AnyActorLogic
Parameters
logic: TLogic
The logic to create an actor from
optionaloptions: ActorOptions<TLogic>
Actor options
Returns Actor<TLogic>
Properties
publicoptional_parent
publicoptional_syncSnapshot
publicclock
The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
publicid
The unique identifier for this actor relative to its parent.
publiclogic
The logic to create an actor from
publicoptions
publicref
publicsessionId
The globally unique process ID for this invocation.
publicsrc
publicsystem
The system to which this actor belongs.
Methods
public[observable]
Returns InteropSubscribable<SnapshotFrom<TLogic>>
publicgetPersistedSnapshot
Obtain the internal state of the actor, which can be persisted.
Returns Snapshot<unknown>
publicgetSnapshot
Read an actor’s snapshot synchronously.
Returns SnapshotFrom<TLogic>
publicsend
Sends an event to the running Actor to trigger a transition.
Parameters
event: EventFromLogic<TLogic>
The event to send
Returns void
publicstart
Starts the Actor from the initial state
Returns Actor<TLogic>
publicstop
Stops the Actor and unsubscribe all listeners.
Returns Actor<TLogic>
publicsubscribe
Subscribe an observer to an actor’s snapshot values.
Parameters
observer: Observer<SnapshotFrom<TLogic>>
Either a plain function that receives the latest snapshot, or an observer object whose
.next(snapshot)
method receives the latest snapshot
Returns Subscription
publictoJSON
Returns { id: string; xstate$$type: number }
id: string
xstate$$type: number
An Actor is a running process that can receive events, send events and change its behavior based on the events it receives, which can cause effects outside of the actor. When you run a state machine, it becomes an actor.