Basically, it's a generator whose next returns a promise for the next value. Like an observable but much lazier. When multiple values are concerned there are big differences between push and pull semantics.
@BenjaminGruenbaum I see that much clearly now. I have entirely the same feelings as this comment: github.com/zenparsing/async-iteration/issues/…. Conditionally unwrapping based on a type check on consumer side is a good idea as well.
The good idea in term of soundness would have probably been to never automatically unwrap to begin with and make people only yield promises. That would have confused developers though who just want "async to work"
For example: I map a url to a stream of its data, and I want to have streams of all the requests (but not start them), then I want to start them conditionally (after a filter) and then merge their subscriptions.
With promises it's easier, but that's not really a fair comparison because promises are already started actions - for example to start everything at once.
@BenjaminGruenbaum Right, but I can't see any use cases to do that in userland code. Since people are used to .then of Promise objects being a flatMap as well, it seems people also want streams to auto flatmap
room topic changed to ECMAScript: For high level discussion of the ECMAScript language. Spec discussion, discussion of libraries you're contributing to, high level stuff - welcome. Support questions are not. [ecmascript]
room topic changed to ECMAScript: For high level discussion of the ECMAScript language. Spec discussion, discussion of libraries you're contributing to, high level stuff - welcome. Support questions are not. [ecmascript] [es-2015] [es-2016]
If you are a JS room regular and would like to be invited - feel free to request access.
@BenjaminGruenbaum by off the shelf solutions you mean current implementations in servers and browsers? I haven't benchmarked myself but cloudflare guys say it is working well for them and those using cloudflare
I have tested nginx 1.9.5 mainline for 5 megs of data transfer split between 30+ files (images, css, js) all gzipped with ssl. It wasn't observably faster than the equivalent HTTP1 setup, but devtools and logs did indicate speedups
(It is nowhere near a real world test though. just refreshed a couple of times and collected logs)
@MadaraUchiha in stackoverflow.com/a/34706771/1348195 you might want to aggregate errors. Other than that it mostly looks good - I might execute it in a Promise.resolve to convert throws to rejections