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

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

Issue 14070010: Refactor Future constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added co19 issue number. 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
« no previous file with comments | « sdk/lib/async/future.dart ('k') | sdk/lib/indexed_db/dart2js/indexed_db_dart2js.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 deprecatedFutureValue(_FutureImpl future) => 7 deprecatedFutureValue(_FutureImpl future) =>
8 future._isComplete ? future._resultOrListeners : null; 8 future._isComplete ? future._resultOrListeners : null;
9 9
10 class _CompleterImpl<T> implements Completer<T> { 10 class _CompleterImpl<T> implements Completer<T> {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 future.catchError(handleError).then((Object value) { 127 future.catchError(handleError).then((Object value) {
128 if (values == null) return null; 128 if (values == null) return null;
129 values[pos] = value; 129 values[pos] = value;
130 remaining--; 130 remaining--;
131 if (remaining == 0) { 131 if (remaining == 0) {
132 completer.complete(values); 132 completer.complete(values);
133 } 133 }
134 }); 134 });
135 } 135 }
136 if (remaining == 0) { 136 if (remaining == 0) {
137 return new Future.immediate(const []); 137 return new Future.value(const []);
138 } 138 }
139 values = new List(remaining); 139 values = new List(remaining);
140 completer = new Completer<List>(); 140 completer = new Completer<List>();
141 return completer.future; 141 return completer.future;
142 } 142 }
143 143
144 Future then(f(T value), { onError(error) }) { 144 Future then(f(T value), { onError(error) }) {
145 if (!_isComplete) { 145 if (!_isComplete) {
146 if (onError == null) { 146 if (onError == null) {
147 return new _ThenFuture(f).._subscribeTo(this); 147 return new _ThenFuture(f).._subscribeTo(this);
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 Future catchError(function(error), {bool test(var error)}) { 508 Future catchError(function(error), {bool test(var error)}) {
509 return _future.catchError(function, test: test); 509 return _future.catchError(function, test: test);
510 } 510 }
511 511
512 Future<T> whenComplete(action()) { 512 Future<T> whenComplete(action()) {
513 return _future.whenComplete(action); 513 return _future.whenComplete(action);
514 } 514 }
515 515
516 Stream<T> asStream() => new Stream.fromFuture(_future); 516 Stream<T> asStream() => new Stream.fromFuture(_future);
517 } 517 }
OLDNEW
« no previous file with comments | « sdk/lib/async/future.dart ('k') | sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698