Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: corelib/src/future.dart

Issue 10540036: add a note about completer to future (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 * 21 *
22 * When a future completes: 22 * When a future completes:
23 * 23 *
24 * 1. if the future suceeded, handlers registered with [then] are called. 24 * 1. if the future suceeded, handlers registered with [then] are called.
25 * 2. if the future failed, handlers registered with [handleException] are 25 * 2. if the future failed, handlers registered with [handleException] are
26 * called in sequence, until one returns true. 26 * called in sequence, until one returns true.
27 * 3. handlers registered with [onComplete] are called 27 * 3. handlers registered with [onComplete] are called
28 * 4. if the future failed, and at least one handler was registered with 28 * 4. if the future failed, and at least one handler was registered with
29 * [then], and no handler registered with [handleException] returned 29 * [then], and no handler registered with [handleException] returned
30 * [:true:], then the exception is thrown. 30 * [:true:], then the exception is thrown.
31 *
32 * Use a [Completer] to simplify working with futures.
Siggi Cherem (dart-lang) 2012/06/06 22:28:44 rather than simplify, I'd say to actually create t
31 */ 33 */
32 interface Future<T> default FutureImpl<T> { 34 interface Future<T> default FutureImpl<T> {
33 35
34 /** A future whose value is immediately available. */ 36 /** A future whose value is immediately available. */
35 Future.immediate(T value); 37 Future.immediate(T value);
36 38
37 /** The value provided. Throws an exception if [hasValue] is false. */ 39 /** The value provided. Throws an exception if [hasValue] is false. */
38 T get value(); 40 T get value();
39 41
40 /** 42 /**
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 205 }
204 }); 206 });
205 future.handleException((exception) { 207 future.handleException((exception) {
206 if (!result.isComplete) completer.completeException(exception); 208 if (!result.isComplete) completer.completeException(exception);
207 return true; 209 return true;
208 }); 210 });
209 } 211 }
210 return result; 212 return result;
211 } 213 }
212 } 214 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698