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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 import '../stream_channel.dart'; 7 import '../stream_channel.dart';
8 8
9 /// A controller for exposing a new [StreamChannel]. 9 /// A controller for exposing a new [StreamChannel].
10 /// 10 ///
(...skipping 29 matching lines...) Expand all
40 /// This channel should be returned to external users so they can communicate 40 /// This channel should be returned to external users so they can communicate
41 /// with [local]. 41 /// with [local].
42 StreamChannel<T> get foreign => _foreign; 42 StreamChannel<T> get foreign => _foreign;
43 StreamChannel<T> _foreign; 43 StreamChannel<T> _foreign;
44 44
45 /// Creates a [StreamChannelController]. 45 /// Creates a [StreamChannelController].
46 /// 46 ///
47 /// If [sync] is true, events added to either channel's sink are synchronously 47 /// If [sync] is true, events added to either channel's sink are synchronously
48 /// dispatched to the other channel's stream. This should only be done if the 48 /// dispatched to the other channel's stream. This should only be done if the
49 /// source of those events is already asynchronous. 49 /// source of those events is already asynchronous.
50 StreamChannelController({bool sync: false}) { 50 ///
51 /// If [allowForeignErrors] is `false`, errors are not allowed to be passed to
52 /// the foreign channel's sink. If any are, the connection will close and the
53 /// error will be forwarded to the foreign channel's [Sink.done] future. This
54 /// guarantees that the local stream will never emit errors.
55 StreamChannelController({bool allowForeignErrors: true, bool sync: false}) {
51 var localToForeignController = new StreamController<T>(sync: sync); 56 var localToForeignController = new StreamController<T>(sync: sync);
52 var foreignToLocalController = new StreamController<T>(sync: sync); 57 var foreignToLocalController = new StreamController<T>(sync: sync);
53 _local = new StreamChannel<T>.withGuarantees( 58 _local = new StreamChannel<T>.withGuarantees(
54 foreignToLocalController.stream, localToForeignController.sink); 59 foreignToLocalController.stream, localToForeignController.sink);
55 _foreign = new StreamChannel<T>.withGuarantees( 60 _foreign = new StreamChannel<T>.withGuarantees(
56 localToForeignController.stream, foreignToLocalController.sink); 61 localToForeignController.stream, foreignToLocalController.sink,
62 allowSinkErrors: allowForeignErrors);
57 } 63 }
58 } 64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698