> It would be great to have await, but in the meantime having generator
> functions would help male async methods tolerable. Await is ES7 at the
> earliest, generator arrow functions could be in ES6.
Couldn’t arrow generator functions replace generator function declarations? In
other words: is the dynamic `this` in generator function declarations ever
useful?
Then we’d have a nice symmetry in ES6:
– non-method function = const + arrow function.
– method = concise method definition
– non-method generator function = const + arrow generator function.
– generator method = concise generator method definition
That would make the async programming code more compact, too (I’m assuming a
nullary paren-free arrow variant and I prefer the asterisk after the arrow):
```js
spawn(=>* {
var data = yield $.ajax(url);
$('#result').html(data);
var status = $('#status').html('Download complete.');
yield status.fadeIn().promise();
yield sleep(2000);
status.fadeOut();
});
```
Versus:
```js
spawn(function*() {
var data = yield $.ajax(url);
$('#result').html(data);
var status = $('#status').html('Download complete.');
yield status.fadeIn().promise();
yield sleep(2000);
status.fadeOut();
});
```
[Example taken from task.js website.]
--
Dr. Axel Rauschmayer
[email protected]
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss