Posts

Showing posts from October, 2014

Dart's Async / Await is here. The Future starts now

Image
The latest development release of the Dart Editor  includes experimental support for Async / Await.  Check out Gilad's article for an introduction. In the Editor go into preferences -> experimental to enable this feature. async / await is "syntactic sugar" for what can be accomplished using Futures, Completors and a whack of nested then() closures. But this sugar is ohh so sweet (and calorie free!).  Your code will be much easier to understand and debug. Here is a little before and after example using async/await. In this example, we need to perform 3 async LDAP operations in sequence. Using Futures and nested then() closures, we get something like this: // add mickey to directory ldap.add(dn, attrs).then( expectAsync((r) { expect( r.resultCode, equals(0)); // modify mickey's sn var m = new Modification.replace("sn", ["Sir Mickey"]); ldap.modify(dn, [m]).then( expectAsync((result) { ex