Actor<M, A> class

An Actor is an entity that can send messages to a Handler running inside a Dart Isolate.

It can be seen as the local view of the isolated Handler that handles messages sent via the Actor, communicating with the associated Isolate in a transparent manner.

Actors are mapped 1-1 to Isolates in the Dart VM, so the limitations of Isolates also apply to Actors:

  • messages sent to Actors must be copied into the Isolate the Actor is running on unless the DartVM can infer the message is immutable.
  • not all Dart objects can be sent to an Actor, see the limitations in SendPort.send for details.

Notice that an Actor cannot return a Stream of any kind, only a single FutureOr of type A. To return a Stream, use StreamActor instead.

On the web, Actors do not have an isolated environment. For this reason, Actors that rely on mutable global variables being "isolated" to themselves are not fully portable.

Mixed in types
Implementers

Constructors

Actor(Handler<M, A> handler)
Creates an Actor that handles messages with the given Handler.
Actor.create(Handler<M, A> createHandler())
Creates an Actor that handles messages with the Handler returned by the createHandler function.
Actor.of(HandlerFunction<M, A> handler)
Creates an Actor based on a handler function.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() FutureOr<void>
Close this Actor.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send(M message) FutureOr<A>
Send a message to the Handler this Actor is based on.
override
toSendable() Future<Sendable<M, A>>
A handle to this Actor which can be sent to other actors.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited