Honestly Isiah my largest motivation for thinking this is worth solving boils down to the fact that async/await does a good job of hiding the promise and generator based implementation under it but this falls down so fast when adding Promise.all.
I'm helping a new person learn JavaScript right now and he's using fetch to get some JSON. Explaining the first then returning res.json() and the second one chaining as well as 'this' considerations was a disaster. He conceptually understands asynchronous code so when I backed up and did the same thing with async/await he just got it. Saving him from needing to learn anything about promises until later on. In my opinion if a layer of sugar doesn't fully abstract the layers it sits upon then it's an incomplete and confusing feature. I'd go so far as to say that async/await should always support every capability of promise without anyone touching Promise directly. On Mar 3, 2017 9:12 PM, "Isiah Meadows" <isiahmead...@gmail.com> wrote: > First, I'll start out with this: I tend to be very adverse to new syntax, > but I'll draw exceptions for things that enable whole new ways of looking > at and manipulating code, like async functions and decorators, or things > that enable new functionality altogether, like `function.sent` or private > class fields. Things that haven't hit that bar for me include the bind > syntax proposal (beyond function pipelining) and the > `await.all`/`await.race` idea here. > > BTW, I had some ideas on unifying that with observables at the syntax > level here, particularly with my `parallel` and `await parallel` ideas > there: https://github.com/tc39/proposal-observable/issues/141 > > Basically, it unifies the common case of merging promises and observables > with a fairly low syntactic footprint. > > As for `Promise.race`, I see it much less frequently, and it's much > simpler and faster under the hood to implement due to less state needed, so > I didn't see the need to add support for that. > > > ----- > > Isiah Meadows > m...@isiahmeadows.com > > On Fri, Mar 3, 2017 at 11:59 AM, Michał Wadas <michalwa...@gmail.com> > wrote: > >> My mistake Array.from is not necessary because Promise.all accepts any >> iterable. >> >> Though I don't believe .race to be common use case (especially when we >> consider it's edge case with empty array). >> >> Hsving parity with spread and rest parameters seems consistent for me. >> >> On 3 Mar 2017 17:54, "T.J. Crowder" <tj.crow...@farsightsoftware.com> >> wrote: >> >>> On Fri, Mar 3, 2017 at 4:51 PM, Michał Wadas <michalwa...@gmail.com> >>> wrote: >>> > Actually I would go with >>> > >>> > await ...expr; >>> > >>> > As sugar for: >>> > >>> > await Promise.all(Array.from(expr)) >>> >>> Which is great for `Promise.all`, but leaves us without `race` or things >>> that may be added in future (like Andrea's `any`). (Granted `all` has to be >>> the dominant use case...) >>> >>> Why the `Array.from` part of that? >>> >>> -- T.J. >>> >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> >> > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss