Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(653)

Unified Diff: lib/src/stream_channel_controller.dart

Issue 1669953002: Provide more error-handling customization. (Closed) Base URL: git@github.com:dart-lang/stream_channel.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/src/stream_channel_controller.dart
diff --git a/lib/src/stream_channel_controller.dart b/lib/src/stream_channel_controller.dart
index 1812a0e3a3f48d95d070e5f34c65b365b0d88b04..ad78323effb2e9402614553ca5c6da42a6f04ac3 100644
--- a/lib/src/stream_channel_controller.dart
+++ b/lib/src/stream_channel_controller.dart
@@ -47,12 +47,18 @@ class StreamChannelController<T> {
/// 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.
- StreamChannelController({bool sync: false}) {
+ ///
+ /// 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 [Sink.done] future. This
+ /// guarantees that the local stream will never emit errors.
+ 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);
+ localToForeignController.stream, foreignToLocalController.sink,
+ allowSinkErrors: allowForeignErrors);
}
}

Powered by Google App Engine
This is Rietveld 408576698