Dart API Referencedart:isolateReceivePort

ReceivePort Interface

ReceivePorts, together with SendPorts, are the only means of communication between isolates. ReceivePorts have a toSendPort method which returns a SendPort. Any message that is sent through this SendPort is delivered to the ReceivePort it has been created from. There, they are dispatched to the callback that has been registered on the receive port.

A ReceivePort may have many SendPorts.

Constructors

Code new ReceivePort() #

Opens a long-lived port for receiving messages. The returned port must be explicitly closed through ReceivePort.close.

ReceivePort();

Methods

Code void close() #

Closes this receive port immediately. Pending messages will not be processed and it is impossible to re-open the port. Single-shot reply ports, such as those created through SendPort.call, are automatically closed when the reply has been received. Multiple invocations of close are allowed but ignored.

void close();

Code void receive(void callback(message, SendPort replyTo)) #

Sets up a callback function for receiving pending or future messages on this receive port.

void receive(void callback(var message, SendPort replyTo));

Code SendPort toSendPort() #

Creates a new send port that sends to this receive port. It is legal to create several SendPorts from the same ReceivePort.

SendPort toSendPort();