| 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 | 10 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 future.catchError(handleError).then((Object value) { | 132 future.catchError(handleError).then((Object value) { |
| 133 if (values == null) return null; | 133 if (values == null) return null; |
| 134 values[pos] = value; | 134 values[pos] = value; |
| 135 remaining--; | 135 remaining--; |
| 136 if (remaining == 0) { | 136 if (remaining == 0) { |
| 137 completer.complete(values); | 137 completer.complete(values); |
| 138 } | 138 } |
| 139 }); | 139 }); |
| 140 } | 140 } |
| 141 if (remaining == 0) { | 141 if (remaining == 0) { |
| 142 return new Future.immediate(const []); | 142 return new Future.value(const []); |
| 143 } | 143 } |
| 144 values = new List(remaining); | 144 values = new List(remaining); |
| 145 completer = new Completer<List>(); | 145 completer = new Completer<List>(); |
| 146 return completer.future; | 146 return completer.future; |
| 147 } | 147 } |
| 148 | 148 |
| 149 Future then(f(T value), { onError(AsyncError error) }) { | 149 Future then(f(T value), { onError(AsyncError error) }) { |
| 150 if (!_isComplete) { | 150 if (!_isComplete) { |
| 151 if (onError == null) { | 151 if (onError == null) { |
| 152 return new _ThenFuture(f).._subscribeTo(this); | 152 return new _ThenFuture(f).._subscribeTo(this); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 Future catchError(function(AsyncError error), {bool test(var error)}) { | 526 Future catchError(function(AsyncError error), {bool test(var error)}) { |
| 527 return _future.catchError(function, test: test); | 527 return _future.catchError(function, test: test); |
| 528 } | 528 } |
| 529 | 529 |
| 530 Future<T> whenComplete(action()) { | 530 Future<T> whenComplete(action()) { |
| 531 return _future.whenComplete(action); | 531 return _future.whenComplete(action); |
| 532 } | 532 } |
| 533 | 533 |
| 534 Stream<T> asStream() => new Stream.fromFuture(_future); | 534 Stream<T> asStream() => new Stream.fromFuture(_future); |
| 535 } | 535 } |
| OLD | NEW |