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

Side by Side Diff: lib/core/future.dart

Issue 10958021: If transformException() returns a future, act like chain(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Refactor out some common code. Created 8 years, 3 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 | lib/coreimpl/future_implementation.dart » ('j') | 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 /** 5 /**
6 * A [Future] is used to obtain a value sometime in the future. Receivers of a 6 * A [Future] is used to obtain a value sometime in the future. Receivers of a
7 * [Future] can obtain the value by passing a callback to [then]. For example: 7 * [Future] can obtain the value by passing a callback to [then]. For example:
8 * 8 *
9 * Future<int> future = getFutureFromSomewhere(); 9 * Future<int> future = getFutureFromSomewhere();
10 * future.then((value) { 10 * future.then((value) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 /** 126 /**
127 * A future representing [transformation] applied to this future's exception. 127 * A future representing [transformation] applied to this future's exception.
128 * This can be used to "catch" an exception coming from `this` and translate 128 * This can be used to "catch" an exception coming from `this` and translate
129 * it to a more appropriate result. 129 * it to a more appropriate result.
130 * 130 *
131 * If this future gets a value, it simply completes to that same value. If an 131 * If this future gets a value, it simply completes to that same value. If an
132 * exception occurs, then [transformation] will be called with the exception 132 * exception occurs, then [transformation] will be called with the exception
133 * value. If [transformation] itself throws an exception, then the returned 133 * value. If [transformation] itself throws an exception, then the returned
134 * future completes with that exception. Otherwise, the future will complete 134 * future completes with that exception. Otherwise, the future will complete
135 * with the value returned by [transformation]. 135 * with the value returned by [transformation]. If the returned value is
136 * itself a future, then the future returned by [transformException] will
137 * complete with the value that that future completes to.
136 */ 138 */
137 Future transformException(transformation(Object exception)); 139 Future transformException(transformation(Object exception));
138 } 140 }
139 141
140 /** 142 /**
141 * A [Completer] is used to produce [Future]s and supply their value when it 143 * A [Completer] is used to produce [Future]s and supply their value when it
142 * becomes available. 144 * becomes available.
143 * 145 *
144 * A service that provides values to callers, and wants to return [Future]s can 146 * A service that provides values to callers, and wants to return [Future]s can
145 * use a [Completer] as follows: 147 * use a [Completer] as follows:
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 future.handleException((exception) { 231 future.handleException((exception) {
230 if (!result.isComplete) { 232 if (!result.isComplete) {
231 completer.completeException(exception, future.stackTrace); 233 completer.completeException(exception, future.stackTrace);
232 } 234 }
233 return true; 235 return true;
234 }); 236 });
235 } 237 }
236 return result; 238 return result;
237 } 239 }
238 } 240 }
OLDNEW
« no previous file with comments | « no previous file | lib/coreimpl/future_implementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698