Chromium Code Reviews| 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 /** | 7 /** |
| 8 * An object representing a delayed computation. | 8 * An object representing a delayed computation. |
| 9 * | 9 * |
| 10 * A [Future] is used to obtain a not yet | 10 * A [Future] is used to obtain a not yet |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 * }); | 480 * }); |
| 481 */ | 481 */ |
| 482 factory Completer.sync() => new _SyncCompleter<T>(); | 482 factory Completer.sync() => new _SyncCompleter<T>(); |
| 483 | 483 |
| 484 /** The future that will contain the result provided to this completer. */ | 484 /** The future that will contain the result provided to this completer. */ |
| 485 Future get future; | 485 Future get future; |
| 486 | 486 |
| 487 /** | 487 /** |
| 488 * Completes [future] with the supplied values. | 488 * Completes [future] with the supplied values. |
| 489 * | 489 * |
| 490 * If the value is itself a future, the completer will wait for that future | |
| 491 * to complete, and complete with the same result, whether it is a success | |
| 492 * or an error. | |
| 493 * | |
| 494 * Calling `complete` or [completeError] must not be done more than once. | |
| 495 * | |
| 490 * All listeners on the future are informed about the value. | 496 * All listeners on the future are informed about the value. |
| 491 */ | 497 */ |
| 492 void complete([T value]); | 498 void complete([value]); |
| 493 | 499 |
| 494 /** | 500 /** |
| 495 * Complete [future] with an error. | 501 * Complete [future] with an error. |
| 496 * | 502 * |
| 503 * Calling [complete] or `completeError` must not be done more than once. | |
| 504 * | |
| 497 * Completing a future with an error indicates that an exception was thrown | 505 * Completing a future with an error indicates that an exception was thrown |
| 498 * while trying to produce a value. | 506 * while trying to produce a value. |
| 499 * | 507 * |
| 500 * The argument [error] must not be `null`. | 508 * The argument [error] must not be `null`, and it must not be a future. |
|
floitsch
2013/10/29 18:13:35
Why this restriction?
I'm ok with it being a futu
Lasse Reichstein Nielsen
2013/10/30 09:22:17
If the result of a future cannot be a future, I as
floitsch
2013/10/30 18:50:53
Error handlers are frequently piped (like for exam
| |
| 501 */ | 509 */ |
| 502 void completeError(Object error, [StackTrace stackTrace]); | 510 void completeError(Object error, [StackTrace stackTrace]); |
| 503 | 511 |
| 504 /** | 512 /** |
| 505 * Whether the future has been completed. | 513 * Whether the future has been completed. |
| 506 */ | 514 */ |
| 507 bool get isCompleted; | 515 bool get isCompleted; |
| 508 } | 516 } |
| OLD | NEW |