IsolateChannel< T> constructor
Creates a stream channel that receives messages from receivePort
and
sends them over sendPort
.
Implementation
factory IsolateChannel(ReceivePort receivePort, SendPort sendPort) {
var controller =
new StreamChannelController<T>(allowForeignErrors: false, sync: true);
receivePort.cast<T>().pipe(controller.local.sink);
controller.local.stream
.listen((data) => sendPort.send(data), onDone: receivePort.close);
return new IsolateChannel._(
controller.foreign.stream, controller.foreign.sink);
}