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

Issue 12091105: Add Future.of that calls a function and captures the result (Closed)

Created:
7 years, 10 months ago by Lasse Reichstein Nielsen
Modified:
7 years, 10 months ago
Reviewers:
floitsch
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add Future.of that calls a function and captures the result This makes new Future.of(func) equivalent to new Future.immediate(null).then((_) => func()) which should kill that idiom. Committed: https://code.google.com/p/dart/source/detail?r=17979

Patch Set 1 #

Patch Set 2 : WIth tests and bugfixes #

Total comments: 5

Patch Set 3 : Reuse _setOrChainValue for Future.of #

Patch Set 4 : Better comment. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+89 lines, -27 lines) Patch
M sdk/lib/async/future.dart View 1 2 3 2 chunks +38 lines, -3 lines 0 comments Download
M sdk/lib/async/future_impl.dart View 1 2 2 chunks +24 lines, -24 lines 0 comments Download
M tests/lib/async/future_test.dart View 1 2 3 chunks +27 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
Lasse Reichstein Nielsen
7 years, 10 months ago (2013-02-01 11:46:26 UTC) #1
floitsch
LGTM. https://codereview.chromium.org/12091105/diff/2001/sdk/lib/async/future.dart File sdk/lib/async/future.dart (right): https://codereview.chromium.org/12091105/diff/2001/sdk/lib/async/future.dart#newcode93 sdk/lib/async/future.dart:93: * will eventually complete with the same result. ...
7 years, 10 months ago (2013-02-01 12:44:11 UTC) #2
Lasse Reichstein Nielsen
7 years, 10 months ago (2013-02-01 13:16:50 UTC) #3
Message was sent while issue was closed.
https://codereview.chromium.org/12091105/diff/2001/sdk/lib/async/future.dart
File sdk/lib/async/future.dart (right):

https://codereview.chromium.org/12091105/diff/2001/sdk/lib/async/future.dart#...
sdk/lib/async/future.dart:93: * will eventually complete with the same result.
I think I'll do it the opposite way:
 new Future.immediate(v) 
where v is not a Future, is equivalent to:
 new Future.of(() => v);

https://codereview.chromium.org/12091105/diff/2001/sdk/lib/async/future.dart#...
sdk/lib/async/future.dart:98: if (result is Future) return new
_FutureWrapper<T>(result);
That was my question too. I decided to do it just to be safe, but I can, easily,
be convinced not to.

Powered by Google App Engine
This is Rietveld 408576698