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

Side by Side Diff: sdk/lib/async/future.dart

Issue 12207044: Update doc for Future.whenComplete. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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) 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 * A [Future] represents a delayed computation. It is used to obtain a not-yet 8 * A [Future] represents a delayed computation. It is used to obtain a not-yet
9 * available value, or error, sometime in the future. Receivers of a 9 * available value, or error, sometime in the future. Receivers of a
10 * [Future] can register callbacks that handle the value or error once it is 10 * [Future] can register callbacks that handle the value or error once it is
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 * The future returned by this call, `f`, will complete the same way 269 * The future returned by this call, `f`, will complete the same way
270 * as this future unless an error occurs in the [action] call, or in 270 * as this future unless an error occurs in the [action] call, or in
271 * a [Future] returned by the [action] call. If the call to [action] 271 * a [Future] returned by the [action] call. If the call to [action]
272 * does not return a future, its return value is ignored. 272 * does not return a future, its return value is ignored.
273 * 273 *
274 * If the call to [action] throws, then `f` is completed with the 274 * If the call to [action] throws, then `f` is completed with the
275 * thrown error. 275 * thrown error.
276 * 276 *
277 * If the call to [action] returns a [Future], `f2`, then completion of 277 * If the call to [action] returns a [Future], `f2`, then completion of
278 * `f` is delayed until `f2` completes. If `f2` completes with 278 * `f` is delayed until `f2` completes. If `f2` completes with
279 * an error, that will be the result of `f` too. 279 * an error, that will be the result of `f` too. The value of `f2` is always
280 * ignored.
280 * 281 *
281 * This method is equivalent to: 282 * This method is equivalent to:
282 * 283 *
283 * Future<T> whenComplete(action()) { 284 * Future<T> whenComplete(action()) {
284 * this.then((v) { 285 * this.then((v) {
285 * action(); 286 * var f2 = action();
287 * if (f2 is Future) return f2.then((_) => v);
286 * return v 288 * return v
287 * }, 289 * },
288 * onError: (AsyncError e) { 290 * onError: (AsyncError e) {
289 * action(); 291 * var f2 = action();
292 * if (f2 is Future) return f2.then((_) { throw e; });
290 * throw e; 293 * throw e;
291 * }); 294 * });
292 * } 295 * }
293 */ 296 */
294 Future<T> whenComplete(action()); 297 Future<T> whenComplete(action());
295 298
296 /** 299 /**
297 * Creates a [Stream] that sends [this]' completion value, data or error, to 300 * Creates a [Stream] that sends [this]' completion value, data or error, to
298 * its subscribers. The stream closes after the completion value. 301 * its subscribers. The stream closes after the completion value.
299 */ 302 */
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 * The argument [exception] should not be `null`. 346 * The argument [exception] should not be `null`.
344 * 347 *
345 * If [exception] is an [AsyncError], it is used directly as the error 348 * If [exception] is an [AsyncError], it is used directly as the error
346 * message sent to the future's listeners, and [stackTrace] is ignored. 349 * message sent to the future's listeners, and [stackTrace] is ignored.
347 * 350 *
348 * Otherwise the [exception] and an optional [stackTrace] is combined into an 351 * Otherwise the [exception] and an optional [stackTrace] is combined into an
349 * [AsyncError] and sent to this future's listeners. 352 * [AsyncError] and sent to this future's listeners.
350 */ 353 */
351 void completeError(Object exception, [Object stackTrace]); 354 void completeError(Object exception, [Object stackTrace]);
352 } 355 }
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