Re: Stream + async await

2017-08-03 Thread Naveen Chawla
-------- > *From:* Jan-Ivar Bruaroey <j...@mozilla.com> <j...@mozilla.com> > *Sent:* Aug 1, 2017 3:47 PM > *To:* es-discuss@mozilla.org > *Subject:* Re: Stream + async await > > Because a promise is not a control surface of the asynchronous action > fulfilling

Re: Stream + async await

2017-08-02 Thread Jan-Ivar Bruaroey
-Ivar :. On 8/1/17 4:29 PM, Domenic Denicola wrote: That is not why. *From:* Jan-Ivar Bruaroey <j...@mozilla.com> *Sent:* Aug 1, 2017 3:47 PM *To:* es-discuss@mozilla.org *Subject:* Re: Stream + async await Because a

Re: Stream + async await

2017-08-01 Thread Domenic Denicola
That is not why. From: Jan-Ivar Bruaroey <j...@mozilla.com> Sent: Aug 1, 2017 3:47 PM To: es-discuss@mozilla.org Subject: Re: Stream + async await Because a promise is not a control surface of the asynchronous action fulfilling it; confuses owner with co

Re: Stream + async await

2017-08-01 Thread Jan-Ivar Bruaroey
Because a promise is not a control surface of the asynchronous action fulfilling it; confuses owner with consumer. https://stackoverflow.com/a/41417429/918910 .: Jan-Ivar :. On 7/31/17 7:35 AM, T.J. Crowder wrote: Related: https://esdiscuss.org/topic/how-about-awaiting-arrays (particularly

Re: Stream + async await

2017-07-31 Thread T.J. Crowder
Related: https://esdiscuss.org/topic/how-about-awaiting-arrays (particularly the discussion of `await.race`), since effectively you're doing a race between a timeout and each chunk. Also relevant is the former work on cancelling promises, now withdrawn. (Can anyone point me at *why* it was

Re: Stream + async await

2017-07-31 Thread Naveen Chawla
OK let me correct myself. That's preposterous. You have to `await` a promise to kick off it's process. But my point about being able to assign the promise to a wider-scoped `currentRequestItemPromise` before awaiting it which seems impossible with async iterators, which rejects upon timeout,

Re: Stream + async await

2017-07-31 Thread Naveen Chawla
Yes, you need to intervene and reject the latest promise upon timeout (by having a reference to its "reject" callback). This makes me wonder (and I'd like to be corrected if wrong) if async iterators are more of a hindrance than a help? We can currently do a loop over an array of promises,

Re: Stream + async await

2017-07-30 Thread kai zhu
the timeout handler will not work as advertised, e.g. what if io / db issues causes a network stream to intermittently respond in intervals far greater than 3ms or not at all? > On Jul 31, 2017, at 7:26 AM, James Browning wrote: > > It'll look something like

Re: Re: Stream + async await

2017-07-30 Thread James Browning
It'll look something like this: ```javascript async function consumeReadableStream(stream) {     const start = Date.now()     for await (const chunk of stream) { /* Do whatever you want with the chunk here e,g, await other async tasks with chunks send them off to wherever,

Re: Stream + async await

2017-07-30 Thread kai zhu
> <mailto:d...@domenic.me>> wrote: > https://github.com/tc39/proposal-async-iteration > <https://github.com/tc39/proposal-async-iteration> > > > From: es-discuss [mailto:es-discuss-boun...@mozilla.org > <mailto:es-discuss-boun...@mozilla.org>] On Behalf

Re: Stream + async await

2017-07-30 Thread Naveen Chawla
't be surprised if >> you've already thought about this! (If you're too busy I'm sure there are >> others here familiar with it too!) >> >> On Tue, 11 Jul 2017 at 21:09 Domenic Denicola <d...@domenic.me> wrote: >> >>> https://github.com/tc39/pro

Re: Stream + async await

2017-07-29 Thread Isiah Meadows
> >> *From:* es-discuss [mailto:es-discuss-boun...@mozilla.org] *On Behalf Of >> *Naveen Chawla >> *Sent:* Tuesday, July 11, 2017 09:24 >> *To:* es-discuss@mozilla.org >> *Subject:* Stream + async await >> >> >> >> It'd be great to have async stream

RE: Stream + async await

2017-07-29 Thread Ron Buckton
omenic Denicola<mailto:d...@domenic.me>; es-discuss@mozilla.org<mailto:es-discuss@mozilla.org> Subject: Re: Stream + async await Interesting!!! Excuse my ignorance, but with this construct, how would you trivially invoke a "publish" ahead of any given "consumption"

Re: Stream + async await

2017-07-29 Thread Naveen Chawla
On Behalf Of > *Naveen > Chawla > *Sent:* Tuesday, July 11, 2017 09:24 > *To:* es-discuss@mozilla.org > *Subject:* Stream + async await > > > > It'd be great to have async stream constructs such as: > http://reactivex.io/rxjs/ , supported natively, such that they can

RE: Stream + async await

2017-07-11 Thread Domenic Denicola
https://github.com/tc39/proposal-async-iteration From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Naveen Chawla Sent: Tuesday, July 11, 2017 09:24 To: es-discuss@mozilla.org Subject: Stream + async await It'd be great to have async stream constructs such as: http

Stream + async await

2017-07-11 Thread Naveen Chawla
It'd be great to have async stream constructs such as: http://reactivex.io/rxjs/ , supported natively, such that they can be used directly with the async / await keywords for async stream programming in a linear fashion (analogous to what can already be done with linearly awaiting Promises, but