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

Unified Diff: sdk/lib/_internal/pub/lib/src/error_group.dart

Issue 18428003: Fix pub errorgroup and analyzer errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | tests/lib/async/stream_state_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/error_group.dart
diff --git a/sdk/lib/_internal/pub/lib/src/error_group.dart b/sdk/lib/_internal/pub/lib/src/error_group.dart
index cc7b0071b3d82b4eda21a1fe63faecee17ea10ed..b49b45a3702b3ffbdaeeec7f15140c071bcf1279 100644
--- a/sdk/lib/_internal/pub/lib/src/error_group.dart
+++ b/sdk/lib/_internal/pub/lib/src/error_group.dart
@@ -225,6 +225,10 @@ class _ErrorGroupStream extends Stream {
/// The underlying [StreamController] for [this].
final StreamController _controller;
+ /// The controller's [Stream]. May be different than `_controller.stream` if
+ /// the wrapped stream is a broadcasting stream.
+ Stream _stream;
+
/// The [StreamSubscription] that connects the wrapped [Stream] to
/// [_controller].
StreamSubscription _subscription;
@@ -235,9 +239,12 @@ class _ErrorGroupStream extends Stream {
/// Creates a new [_ErrorGroupFuture] that's a child of [_group] and wraps
/// [inner].
_ErrorGroupStream(this._group, Stream inner)
- : _controller =
- inner.isBroadcast ? new StreamController.broadcast(sync: true)
- : new StreamController(sync: true) {
+ : _controller = new StreamController(sync: true) {
+ // Use old-style asBroadcastStream behavior - cancel source _subscription
+ // the first time the stream has no listeners.
+ _stream = inner.isBroadcast
+ ? _controller.stream.asBroadcastStream(onCancel: (sub) => sub.cancel())
+ : _controller.stream;
_subscription = inner.listen((v) {
_controller.add(v);
}, onError: (e) {
@@ -252,7 +259,7 @@ class _ErrorGroupStream extends Stream {
StreamSubscription listen(void onData(value),
{void onError(var error), void onDone(),
bool cancelOnError}) {
- return _controller.stream.listen(onData,
+ return _stream.listen(onData,
onError: onError,
onDone: onDone,
cancelOnError: true);
« no previous file with comments | « no previous file | tests/lib/async/stream_state_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698