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

Side by Side Diff: utils/pub/error_group.dart

Issue 12049013: Change singleSubscription/multiSubscription to normal/broadcast. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments, renamed .multiSubscription to .broadcast. Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library error_group; 5 library error_group;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 /// An [ErrorGroup] entangles the errors of multiple [Future]s and [Stream]s 9 /// An [ErrorGroup] entangles the errors of multiple [Future]s and [Stream]s
10 /// with one another. This allows APIs to expose multiple [Future]s and 10 /// with one another. This allows APIs to expose multiple [Future]s and
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 /// The [StreamSubscription] that connects the wrapped [Stream] to 226 /// The [StreamSubscription] that connects the wrapped [Stream] to
227 /// [_controller]. 227 /// [_controller].
228 StreamSubscription _subscription; 228 StreamSubscription _subscription;
229 229
230 /// Whether [this] has any listeners. 230 /// Whether [this] has any listeners.
231 bool get _hasListeners => _controller.hasSubscribers; 231 bool get _hasListeners => _controller.hasSubscribers;
232 232
233 /// Creates a new [_ErrorGroupFuture] that's a child of [_group] and wraps 233 /// Creates a new [_ErrorGroupFuture] that's a child of [_group] and wraps
234 /// [inner]. 234 /// [inner].
235 _ErrorGroupStream(this._group, Stream inner) 235 _ErrorGroupStream(this._group, Stream inner)
236 : _controller = inner.isSingleSubscription ? 236 : _controller = inner.isBroadcast ?
237 new StreamController() : 237 new StreamController.broadcast() :
238 new StreamController.multiSubscription() { 238 new StreamController() {
239 _subscription = inner.listen(_controller.add, 239 _subscription = inner.listen(_controller.add,
240 onError: (e) => _group._signalError(e), 240 onError: (e) => _group._signalError(e),
241 onDone: () { 241 onDone: () {
242 _isDone = true; 242 _isDone = true;
243 _group._signalStreamComplete(this); 243 _group._signalStreamComplete(this);
244 _controller.close(); 244 _controller.close();
245 }); 245 });
246 } 246 }
247 247
248 StreamSubscription listen(void onData(value), 248 StreamSubscription listen(void onData(value),
(...skipping 10 matching lines...) Expand all
259 void _signalError(AsyncError e) { 259 void _signalError(AsyncError e) {
260 if (_isDone) return; 260 if (_isDone) return;
261 _subscription.cancel(); 261 _subscription.cancel();
262 // Call these asynchronously to work around issue 7913. 262 // Call these asynchronously to work around issue 7913.
263 new Future.immediate(null).then((_) { 263 new Future.immediate(null).then((_) {
264 _controller.signalError(e.error, e.stackTrace); 264 _controller.signalError(e.error, e.stackTrace);
265 _controller.close(); 265 _controller.close();
266 }); 266 });
267 } 267 }
268 } 268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698