--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
Future _pendingLoad;Future load() {// If we're already in-progress, use the same future.if (_pendingLoad != null) return _pendingLoad;_pendingLoad = ...;}
It *could* be written like that, but whether it *should* is entirely up to the author. There are things you can do with futures that has no corresponding syntax, but most of the common users will probably be doable, and more readable, with the new syntax.
Personally I'll likely use temporary variables for await expressions:
var response = await client.post(...);
print (response.body);
/L
Ob-pedantry: The example actually works even if the initial part isn't synchronous. The first function body to be executed will set the pending future, and late bodies will return it, no matter which one was actually called first. The only difference is that you don't return an identical future, just an equivalent one.
Ob-pedantry: The example actually works even if the initial part isn't synchronous. The first function body to be executed will set the pending future, and late bodies will return it, no matter which one was actually called first. The only difference is that you don't return an identical future, just an equivalent one.
Future _pendingLoad;Future load() async {
// If we're already in-progress, use the same future.if (_pendingLoad != null) return _pendingLoad;
return _pendingLoad = foo(await bar());}
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
--
Bob, out of curiosity, how would you write this with the dart:async API? The assignment to _pendingLoad can't come in bar's then handler anyway, or can it?
Future _pendingLoad;Future load() {
// If we're already in-progress, use the same future.if (_pendingLoad != null) return _pendingLoad;
return _pendingLoad = bar().then(foo);}
Would it be possible to kick off a new build of the dev channel? Async-await support was added to the Dart Editor in rev 41297, but currently the last dev build was based on rev 41145.
The features described in this article are still under development. Not all the parts of the system necessarily comply with the spec.
Overall, you should regard this article as a heads up for early adopters.
A short article about async-await in Dart is on our web site:
--
We know which functions are async, and we know that, when we use their values, we must await.
identity(value) => value;
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.