| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |