On 24 February 2017 at 16:19:03, Šime Vidas ([email protected]) wrote:
> To clarify, the idea is to declare and kick off all the concurrent tasks
> upfront
Well, that's what promises *already* do, even without using the
`async` and `await` keywords. You kick off all concurrent tasks
up-front - it's only tasks that depend on a previous task's result
that need wait around for that task to finish. Without `async`
functions, you'd probably do something like this:
function makePizza(sauceType = 'red') {
const dough = makeDough(), sauce = makeSauce(sauceType);
const cheese = sauce.then(s => grateCheese(s.determineCheese()));
return Promise.all([dough, sauce, cheese]).then(function([dough,
sauce, cheese]) {
dough.add(sauce);
dough.add(cheese);
return dough;
}
}
With `async` functions, you can avoid all those lambdas and the code's
a little bit cleaner - either way, you don't need new JS magic to do
things concurrently!
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss