| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Dart core library. | 5 // Dart core library. |
| 6 | 6 |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * A [Future] is used to obtain a value sometime in the future. Receivers of a | 9 * A [Future] is used to obtain a value sometime in the future. Receivers of a |
| 10 * [Future] can obtain the value by passing a callback to [then]. | 10 * [Future] can obtain the value by passing a callback to [then]. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 void handleException(bool onException(Object exception)); | 90 void handleException(bool onException(Object exception)); |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * A future representing [transformation] applied to this future's value. | 93 * A future representing [transformation] applied to this future's value. |
| 94 * | 94 * |
| 95 * When this future gets a value, [transformation] will be called on the | 95 * When this future gets a value, [transformation] will be called on the |
| 96 * value, and the returned future will receive the result. | 96 * value, and the returned future will receive the result. |
| 97 * | 97 * |
| 98 * If an exception occurs (received by this future, or thrown by | 98 * If an exception occurs (received by this future, or thrown by |
| 99 * [transformation]) then the returned future will receive the exception. | 99 * [transformation]) then the returned future will receive the exception. |
| 100 * |
| 101 * You must not add exception handlers to [this] future prior to calling |
| 102 * transform, and any you add afterwards will not be invoked. |
| 100 */ | 103 */ |
| 101 Future transform(transformation(T value)); | 104 Future transform(transformation(T value)); |
| 102 | 105 |
| 103 /** | 106 /** |
| 104 * A future representing an asynchronous transformation applied to this | 107 * A future representing an asynchronous transformation applied to this |
| 105 * future's value. [transformation] must return a Future. | 108 * future's value. [transformation] must return a Future. |
| 106 * | 109 * |
| 107 * When this future gets a value, [transformation] will be called on the | 110 * When this future gets a value, [transformation] will be called on the |
| 108 * value. When the resulting future gets a value, the returned future | 111 * value. When the resulting future gets a value, the returned future |
| 109 * will receive it. | 112 * will receive it. |
| 110 * | 113 * |
| 111 * If an exception occurs (received by this future, thrown by | 114 * If an exception occurs (received by this future, thrown by |
| 112 * [transformation], or received by the future returned by [transformation]) | 115 * [transformation], or received by the future returned by [transformation]) |
| 113 * then the returned future will receive the exception. | 116 * then the returned future will receive the exception. |
| 117 * |
| 118 * You must not add exception handlers to [this] future prior to calling |
| 119 * chain, and any you add afterwards will not be invoked. |
| 114 */ | 120 */ |
| 115 Future chain(Future transformation(T value)); | 121 Future chain(Future transformation(T value)); |
| 116 } | 122 } |
| 117 | 123 |
| 118 | 124 |
| 119 /** | 125 /** |
| 120 * A [Completer] is used to produce [Future]s and supply their value when it | 126 * A [Completer] is used to produce [Future]s and supply their value when it |
| 121 * becomes available. | 127 * becomes available. |
| 122 * | 128 * |
| 123 * A service that provides values to callers, and wants to return [Future]s can | 129 * A service that provides values to callers, and wants to return [Future]s can |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 211 } |
| 206 }); | 212 }); |
| 207 future.handleException((exception) { | 213 future.handleException((exception) { |
| 208 if (!result.isComplete) completer.completeException(exception); | 214 if (!result.isComplete) completer.completeException(exception); |
| 209 return true; | 215 return true; |
| 210 }); | 216 }); |
| 211 } | 217 } |
| 212 return result; | 218 return result; |
| 213 } | 219 } |
| 214 } | 220 } |
| OLD | NEW |