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

Unified Diff: utils/pub/utils.dart

Issue 12452008: Stop working around issue 8512. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « utils/pub/error_group.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/utils.dart
diff --git a/utils/pub/utils.dart b/utils/pub/utils.dart
index fd130da7ee1dfa4e62f3dec9aed430f058ae85a3..20aa140a6510f13e323b503ac57bfba4921232c5 100644
--- a/utils/pub/utils.dart
+++ b/utils/pub/utils.dart
@@ -173,24 +173,15 @@ void chainToCompleter(Future future, Completer completer) {
/// Returns a [Future] that will complete to the first element of [stream].
/// Unlike [Stream.first], this is safe to use with single-subscription streams.
Future streamFirst(Stream stream) {
- // TODO(nweiz): remove this when issue 8512 is fixed.
- var cancelled = false;
var completer = new Completer();
var subscription;
subscription = stream.listen((value) {
- if (!cancelled) {
- cancelled = true;
- subscription.cancel();
- completer.complete(value);
- }
+ subscription.cancel();
+ completer.complete(value);
}, onError: (e) {
- if (!cancelled) {
- completer.completeError(e.error, e.stackTrace);
- }
+ completer.completeError(e.error, e.stackTrace);
}, onDone: () {
- if (!cancelled) {
- completer.completeError(new StateError("No elements"));
- }
+ completer.completeError(new StateError("No elements"));
}, unsubscribeOnError: true);
return completer.future;
}
« no previous file with comments | « utils/pub/error_group.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698