IsolateChild<S, R> class abstract

A child isolate that is spawned by another isolate.

A subclass of this should override id to uniquely identify itself among other children. Override onData to handle data sent by the parent isolate, and call send to send data back to the parent. Override run to run code when the child isolate is spawned.

The type arguments S and R represent the types of data that will be Sent and Received, from the child isolate's perspective. That is, if the parent sends integers and expects Strings, then S on the child should be String and R should be int -- the opposite of the parent.

Constructors

IsolateChild({required Object id})
Creates an isolate child with the given ID.

Properties

hashCode int
The hash code for this object.
no setterinherited
id Object
The ID of this child. Used to identify it to the parent.
final
receiver ↔ TypedReceivePort<R>
The type-safe ReceivePort that will receive messages of type R from the parent.
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

init(TypedSendPort<IsolatePayload<S, R>> port) → void
Saves the given TypedSendPort, and creates a TypedReceivePort to send to the parent.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onData(R data) → void
A callback to run when new data is received from the parent.
run() → void
Runs when the child isolate is spawned, after init is called.
send(S obj) → void
Sends data to the parent.
toString() String
A string representation of this object.
inherited

Operators

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