3 ms·
> `async function foo() { const a = await bar();` vs `co(function* foo() { const a = yield bar();` isn't really with adding extra syntax for. I'd rather pick a
by tiborsaas 7y ago
> `async function foo() { const a = await bar();` vs `co(function* foo() { const a = yield bar();` isn't really with adding extra syntax for.
I'd rather pick a standard solution over a library. I never used CO, because I didn't see the benefits of pulling this library in over plain ol' promises. The cognitive overload of generators, yielding, thunks and changing api-s is just too much IMHO, I like simpler things that work just as well.
With the await keyword baked into the language I can simply think of "if anything returns a promise, I can wait for the response in a simple assignment".
- wiremine 7y ago> I'd rather pick a standard solution over a library. This. Rust can be complex enough for engineers new to the language. This sort of feature really requires a standard approach.
- jkoudys 7y agoIt's as standard a solution as any, it just doesn't require changing the language. If you can Promise.all, you can Promise.coroutine. Putting async in front of a function definition requires learning a new syntax, but wrapping a coroutine FN around it builds on knowledge of existing behaviour.