StreamChannelController<T> class

A controller for exposing a new StreamChannel.

This exposes two connected StreamChannels, local and foreign. The user's code should use local to emit and receive events. Then foreign can be returned for others to use. For example, here's a simplified version of the implementation of new IsolateChannel:

StreamChannel isolateChannel(ReceivePort receivePort, SendPort sendPort) {
  var controller = new StreamChannelController(allowForeignErrors: false);

  // Pipe all events from the receive port into the local sink...
  receivePort.pipe(controller.local.sink);

  // ...and all events from the local stream into the send port.
  controller.local.stream.listen(sendPort.send, onDone: receivePort.close);

  // Then return the foreign controller for your users to use.
  return controller.foreign;
}

Constructors

StreamChannelController({bool allowForeignErrors: true, bool sync: false })
Creates a StreamChannelController. [...]

Properties

foreign StreamChannel<T>
The foreign channel. [...]
read-only
local StreamChannel<T>
The local channel. [...]
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited