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

Side by Side Diff: sdk/lib/async/future_impl.dart

Issue 1177343004: Add Stream.empty. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Remove the null future "optimization". Fix some missing type parameters. Created 5 years, 6 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
« no previous file with comments | « no previous file | sdk/lib/async/stream.dart » ('j') | 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 part of dart.async; 5 part of dart.async;
6 6
7 /** The onValue and onError handlers return either a value or a future */ 7 /** The onValue and onError handlers return either a value or a future */
8 typedef dynamic _FutureOnValue<T>(T value); 8 typedef dynamic _FutureOnValue<T>(T value);
9 /** Test used by [Future.catchError] to handle skip some errors. */ 9 /** Test used by [Future.catchError] to handle skip some errors. */
10 typedef bool _FutureErrorTest(var error); 10 typedef bool _FutureErrorTest(var error);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 Future<T> whenComplete(action()) { 227 Future<T> whenComplete(action()) {
228 _Future result = new _Future<T>(); 228 _Future result = new _Future<T>();
229 if (!identical(result._zone, _ROOT_ZONE)) { 229 if (!identical(result._zone, _ROOT_ZONE)) {
230 action = result._zone.registerCallback(action); 230 action = result._zone.registerCallback(action);
231 } 231 }
232 _addListener(new _FutureListener.whenComplete(result, action)); 232 _addListener(new _FutureListener.whenComplete(result, action));
233 return result; 233 return result;
234 } 234 }
235 235
236 Stream<T> asStream() => new Stream.fromFuture(this); 236 Stream<T> asStream() => new Stream<T>.fromFuture(this);
237 237
238 void _markPendingCompletion() { 238 void _markPendingCompletion() {
239 if (!_mayComplete) throw new StateError("Future already completed"); 239 if (!_mayComplete) throw new StateError("Future already completed");
240 _state = _PENDING_COMPLETE; 240 _state = _PENDING_COMPLETE;
241 } 241 }
242 242
243 T get _value { 243 T get _value {
244 assert(_isComplete && _hasValue); 244 assert(_isComplete && _hasValue);
245 return _resultOrListeners; 245 return _resultOrListeners;
246 } 246 }
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 } 652 }
653 }, onError: (e, s) { 653 }, onError: (e, s) {
654 if (timer.isActive) { 654 if (timer.isActive) {
655 timer.cancel(); 655 timer.cancel();
656 result._completeError(e, s); 656 result._completeError(e, s);
657 } 657 }
658 }); 658 });
659 return result; 659 return result;
660 } 660 }
661 } 661 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/async/stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698