StreamChannelController<T> constructor

StreamChannelController<T>({bool allowForeignErrors: true, bool sync: false })

Creates a StreamChannelController.

If sync is true, events added to either channel's sink are synchronously dispatched to the other channel's stream. This should only be done if the source of those events is already asynchronous.

If allowForeignErrors is false, errors are not allowed to be passed to the foreign channel's sink. If any are, the connection will close and the error will be forwarded to the foreign channel's StreamSink.done future. This guarantees that the local stream will never emit errors.

Implementation

StreamChannelController({bool allowForeignErrors: true, bool sync: false}) {
  var localToForeignController = new StreamController<T>(sync: sync);
  var foreignToLocalController = new StreamController<T>(sync: sync);
  _local = new StreamChannel<T>.withGuarantees(
      foreignToLocalController.stream, localToForeignController.sink);
  _foreign = new StreamChannel<T>.withGuarantees(
      localToForeignController.stream, foreignToLocalController.sink,
      allowSinkErrors: allowForeignErrors);
}