3 ms·
This needs a comparison with streams, as opposed to promises. Streams are what you would use to achieve this in Node.js land. https://nodejs.org/api/stream.htm
by olalonde 4y ago
This needs a comparison with streams, as opposed to promises. Streams are what you would use to achieve this in Node.js land.
https://nodejs.org/api/stream.html https://nodejs.org/api/stream.html
- minitech 4y agoWell, the context is Node.js, and I would definitely use promises over streams for what’s described in the article (albeit more directly). Node streams are complicated with a lot of historical baggage, and massive overkill for waiting on a single value produced by another operation.
- olalonde 4y agoThe point was that it's not a single value, it's a stream of values (e.g the compileServer can start working with partial results of the compileBrowser function). Of course if it was a single value, promises are fine. A simpler and more modern alternative would be async iterators/generators[0]. [0] https://blog.logrocket.com/comparing-the-stream-api-and-async-generators-in-node-js-v10/ https://blog.logrocket.com/comparing-the-stream-api-and-asyn...
- minitech 4y ago> The point was that it's not a single value, it's a stream of values But it wasn’t. Despite the author calling it a channel, it only supports one value.