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

Unified Diff: corelib/src/implementation/future_implementation.dart

Issue 10537096: Revert changes to Future.chain() and Future.transform() from http://codereview.chromium.org/10517006 (Closed) Base URL: http://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 side-by-side diff with in-line comments
Download patch
Index: corelib/src/implementation/future_implementation.dart
===================================================================
--- corelib/src/implementation/future_implementation.dart (revision 8478)
+++ corelib/src/implementation/future_implementation.dart (working copy)
@@ -158,14 +158,14 @@
Future transform(Function transformation) {
final completer = new Completer();
- onComplete((f) {
- if (!f.hasValue) {
- completer.completeException(f.exception);
- return;
- }
+ handleException((e) {
+ completer.completeException(e);
+ return true;
+ });
+ then((v) {
var transformed = null;
try {
- transformed = transformation(f.value);
+ transformed = transformation(v);
} catch (final e) {
completer.completeException(e);
return;
@@ -177,21 +177,23 @@
Future chain(Function transformation) {
final completer = new Completer();
- onComplete((f) {
- if (!f.hasValue) {
- completer.completeException(f.exception);
- return;
- }
+ handleException((e) {
+ completer.completeException(e);
+ return true;
+ });
+ then((v) {
var future = null;
try {
- future = transformation(f.value);
+ future = transformation(v);
} catch (final e) {
completer.completeException(e);
return;
}
- future.onComplete((g) => g.hasValue
- ? completer.complete(g.value)
- : completer.completeException(g.exception));
+ future.handleException((e) {
+ completer.completeException(e);
+ return true;
+ });
+ future.then((b) => completer.complete(b));
});
return completer.future;
}

Powered by Google App Engine
This is Rietveld 408576698