| OLD | NEW |
| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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), |
| 249 {void onError(AsyncError error), void onDone(), | 249 {void onError(AsyncError error), void onDone(), |
| 250 bool unsubscribeOnError}) { | 250 bool unsubscribeOnError}) { |
| 251 return _controller.listen(onData, | 251 return _controller.stream.listen(onData, |
| 252 onError: onError, | 252 onError: onError, |
| 253 onDone: onDone, | 253 onDone: onDone, |
| 254 unsubscribeOnError: true); | 254 unsubscribeOnError: true); |
| 255 } | 255 } |
| 256 | 256 |
| 257 /// Signal that an error from [_group] should be propagated through [this], | 257 /// Signal that an error from [_group] should be propagated through [this], |
| 258 /// unless it's already complete. | 258 /// unless it's already complete. |
| 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 } |
| OLD | NEW |