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

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

Issue 14251013: Rename unsubscribeOnError to cancelOnError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
« sdk/lib/async/stream.dart ('K') | « utils/pub/safe_http_server.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /// Generic utility functions. Stuff that should possibly be in core. 5 /// Generic utility functions. Stuff that should possibly be in core.
6 library utils; 6 library utils;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:crypto'; 9 import 'dart:crypto';
10 import 'dart:isolate'; 10 import 'dart:isolate';
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 Future streamFirst(Stream stream) { 165 Future streamFirst(Stream stream) {
166 var completer = new Completer(); 166 var completer = new Completer();
167 var subscription; 167 var subscription;
168 subscription = stream.listen((value) { 168 subscription = stream.listen((value) {
169 subscription.cancel(); 169 subscription.cancel();
170 completer.complete(value); 170 completer.complete(value);
171 }, onError: (e) { 171 }, onError: (e) {
172 completer.completeError(e.error, e.stackTrace); 172 completer.completeError(e.error, e.stackTrace);
173 }, onDone: () { 173 }, onDone: () {
174 completer.completeError(new StateError("No elements")); 174 completer.completeError(new StateError("No elements"));
175 }, unsubscribeOnError: true); 175 }, cancelOnError: true);
176 return completer.future; 176 return completer.future;
177 } 177 }
178 178
179 /// Returns a wrapped version of [stream] along with a [StreamSubscription] that 179 /// Returns a wrapped version of [stream] along with a [StreamSubscription] that
180 /// can be used to control the wrapped stream. 180 /// can be used to control the wrapped stream.
181 Pair<Stream, StreamSubscription> streamWithSubscription(Stream stream) { 181 Pair<Stream, StreamSubscription> streamWithSubscription(Stream stream) {
182 var controller = stream.isBroadcast ? 182 var controller = stream.isBroadcast ?
183 new StreamController.broadcast() : 183 new StreamController.broadcast() :
184 new StreamController(); 184 new StreamController();
185 var subscription = stream.listen(controller.add, 185 var subscription = stream.listen(controller.add,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 .then((resolved) => new Pair(key, resolved))); 350 .then((resolved) => new Pair(key, resolved)));
351 }); 351 });
352 return Future.wait(pairs).then((resolvedPairs) { 352 return Future.wait(pairs).then((resolvedPairs) {
353 var map = {}; 353 var map = {};
354 for (var pair in resolvedPairs) { 354 for (var pair in resolvedPairs) {
355 map[pair.first] = pair.last; 355 map[pair.first] = pair.last;
356 } 356 }
357 return map; 357 return map;
358 }); 358 });
359 } 359 }
OLDNEW
« sdk/lib/async/stream.dart ('K') | « utils/pub/safe_http_server.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698