| 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 /** | 5 /** |
| 6 * A [Future] is used to obtain a value sometime in the future. Receivers of a | 6 * A [Future] is used to obtain a value sometime in the future. Receivers of a |
| 7 * [Future] can obtain the value by passing a callback to [then]. For example: | 7 * [Future] can obtain the value by passing a callback to [then]. For example: |
| 8 * | 8 * |
| 9 * Future<int> future = getFutureFromSomewhere(); | 9 * Future<int> future = getFutureFromSomewhere(); |
| 10 * future.then((value) { | 10 * future.then((value) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 bool get hasValue; | 63 bool get hasValue; |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * When this future is complete (either with a value or with an exception), | 66 * When this future is complete (either with a value or with an exception), |
| 67 * then [complete] is called with the future. | 67 * then [complete] is called with the future. |
| 68 * If [complete] throws an exception, it is ignored. | 68 * If [complete] throws an exception, it is ignored. |
| 69 */ | 69 */ |
| 70 void onComplete(void complete(Future<T> future)); | 70 void onComplete(void complete(Future<T> future)); |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * If this future is complete and has a value, then [onValue] is called | 73 * If this future is complete and has a value, then [onSuccess] is called |
| 74 * with the value. | 74 * with the value. |
| 75 */ | 75 */ |
| 76 void then(void onSuccess(T value)); | 76 void then(void onSuccess(T value)); |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * If this future is complete and has an exception, then call [onException]. | 79 * If this future is complete and has an exception, then call [onException]. |
| 80 * | 80 * |
| 81 * If [onException] returns true, then the exception is considered handled. | 81 * If [onException] returns true, then the exception is considered handled. |
| 82 * | 82 * |
| 83 * If [onException] does not return true (or [handleException] was never | 83 * If [onException] does not return true (or [handleException] was never |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 future.handleException((exception) { | 231 future.handleException((exception) { |
| 232 if (!result.isComplete) { | 232 if (!result.isComplete) { |
| 233 completer.completeException(exception, future.stackTrace); | 233 completer.completeException(exception, future.stackTrace); |
| 234 } | 234 } |
| 235 return true; | 235 return true; |
| 236 }); | 236 }); |
| 237 } | 237 } |
| 238 return result; | 238 return result; |
| 239 } | 239 } |
| 240 } | 240 } |
| OLD | NEW |