Re:Node 5.7.0 (stable) released
by esailija on Friday February 26, 2016 @06:47AM
(#11180931)
coroutines with generators are more powerful (cancellation, automatic resource cleanup when the generator terminates etc) and have worked for a long time out of the box. The only difference is that you write `yield` instead of `await` and `decorator(function*` instead of `async function`
[ Parent
| on HN ]
Babel can transform async functions into Bluebird coroutines, so the best of both worlds - https://www.npmjs.com/package/babel-plugin-transform-async-t...
Yes but with this you lose the powerful features I just mentioned: automatic resource cleanup[1], cancellation, yield handlers.. don't you?
No I think those should work with async functions as it is literally just translating `async` -> `yield`, but worth investigating.
Re:Node 5.7.0 (stable) released
by alfonsodev on Friday February 26, 2016 @08:16AM
(#11181173)
Thanks for commenting on that, I didn't think about those issues. I'll research on how much impact could have on performance.
In the other hand I believe syntax is not the only difference. I'm not full time js dev, but after a quick search, I found Domenic pointing 4 differences here https://esdiscuss.org/topic/does-async-await-solve-a-real-pr...
These seem to be mostly about undecorated generators. 3. Is a legit difference but it is actually a syntax error to do yield 1 + yield 2. So that is fixable in a backward compatible way.
Could you put a reference for the decorator/yield usage? Thanks
Thanks, I will review it.
https://github.com/llambda/koa-boiler/blob/master/app.js#L75 is an example of Bluebird coroutines paired with Koa.