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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 * }); | 401 * }); |
| 402 * } | 402 * } |
| 403 */ | 403 */ |
| 404 Future<T> whenComplete(action()); | 404 Future<T> whenComplete(action()); |
| 405 | 405 |
| 406 /** | 406 /** |
| 407 * Creates a [Stream] that sends [this]' completion value, data or error, to | 407 * Creates a [Stream] that sends [this]' completion value, data or error, to |
| 408 * its subscribers. The stream closes after the completion value. | 408 * its subscribers. The stream closes after the completion value. |
| 409 */ | 409 */ |
| 410 Stream<T> asStream(); | 410 Stream<T> asStream(); |
| 411 | |
| 412 /** | |
| 413 * Time-out the future computation after [timeLimit] has passed. | |
| 414 * | |
| 415 * Returns a new future that completes with the same value as this future, | |
| 416 * if this future completes in time. | |
| 417 * If this future does not complete before `timeLimit` has passed, | |
|
floitsch
2013/11/27 12:31:16
New line before?
Lasse Reichstein Nielsen
2013/11/27 12:54:20
Done.
| |
| 418 * the [onTimeout] action is executed instead, and its result (whether it | |
| 419 * returns or thorws) is used as the result of the returned future. | |
|
floitsch
2013/11/27 12:31:16
throws
Lasse Reichstein Nielsen
2013/11/27 12:54:20
Done.
| |
| 420 */ | |
| 421 Future timeout(Duration timeLimit, onTimeout()); | |
|
floitsch
2013/11/27 12:31:16
I think onTimeout should be optional.
Lasse Reichstein Nielsen
2013/11/27 12:54:20
Done.
| |
| 411 } | 422 } |
| 412 | 423 |
| 413 /** | 424 /** |
| 414 * A way to produce Future objects and to complete them later | 425 * A way to produce Future objects and to complete them later |
| 415 * with a value or error. | 426 * with a value or error. |
| 416 * | 427 * |
| 417 * If you already have a Future, you probably don't need a Completer. | 428 * If you already have a Future, you probably don't need a Completer. |
| 418 * Instead, you can usually use [Future.then], which returns a Future: | 429 * Instead, you can usually use [Future.then], which returns a Future: |
| 419 * | 430 * |
| 420 * Future doStuff(){ | 431 * Future doStuff(){ |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 * theFuture.catchError(thisCompleter.completeError); | 545 * theFuture.catchError(thisCompleter.completeError); |
| 535 * | 546 * |
| 536 */ | 547 */ |
| 537 void completeError(Object error, [StackTrace stackTrace]); | 548 void completeError(Object error, [StackTrace stackTrace]); |
| 538 | 549 |
| 539 /** | 550 /** |
| 540 * Whether the future has been completed. | 551 * Whether the future has been completed. |
| 541 */ | 552 */ |
| 542 bool get isCompleted; | 553 bool get isCompleted; |
| 543 } | 554 } |
| OLD | NEW |