Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

await* [asyncOp(), asyncOp()] -> await Promise.all([asyncOp(), asyncOp()]) ? #61

Closed
timjacobi opened this issue Sep 4, 2015 · 8 comments

Comments

@timjacobi
Copy link

I'm just wondering why it is not included in the proposal. It is already implemented in Babel.

@timjacobi timjacobi changed the title await* [asyncOp(), asyncOp()] -> Promise.all([asyncOp(), asyncOp()]) ? await* [asyncOp(), asyncOp()] -> await Promise.all([asyncOp(), asyncOp()]) ? Sep 4, 2015
@bterlson
Copy link
Member

bterlson commented Sep 4, 2015

It doesn't seem useful to me. If it did something similar to yield* where it saves you from having to write complex loops to get an array of promises I would be OK with it but we just don't need sugar for typing Promise.all IMO.

@bterlson bterlson closed this as completed Sep 4, 2015
@zloirock
Copy link

zloirock commented Sep 4, 2015

My point - await* -> Promise.all very useful and should be returned to the current proposal. Yes, it's only sugar for Promise.all, but this proposal completely sugar for generators and promises.

@domenic
Copy link
Member

domenic commented Sep 4, 2015

And it definitely wouldn't use * because it has no correlation with what * means for generators.

Babel is just not implementing the spec here.

@bterlson
Copy link
Member

bterlson commented Sep 4, 2015

FWIW, there is no reason await * can't stand on its own. There is committee consensus behind this proposal without await * so at this point if people want await * they can champion it as part of a separate proposal.

@arv
Copy link
Member

arv commented Sep 5, 2015

Another point to not do await* now is that we might want to save it for something better.

@timjacobi
Copy link
Author

As @domenic said:

Babel is just not implementing the spec here.

That's all I wanted to know. Thanks! :)

@trusktr
Copy link

trusktr commented Dec 20, 2015

Is there anything besides Promise.all() and Promise.race() that people might want to use async* for? If not, then this idea:

await [one, two, three] // async Promise.all([one, two, three])
await* [one, two, three] // async Promise.race([one, two, three])

@ljharb
Copy link
Member

ljharb commented Dec 20, 2015

@trusktr it'd be await not async, but await [one, two, three] is a promise for an array of three things.

There's virtually no value in providing a syntax shortcut for Promise.all and Promise.race - just type them out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants