Hacker News new | ask | show | jobs
by jc123 4273 days ago
Will promises still be needed with generators?
3 comments

They work together very nicely. See taskjs (http://taskjs.org/) for an example. ES7 is considering embracing that pattern with some syntax sugar (http://wiki.ecmascript.org/doku.php?id=strawman:async_functi...).
Generators dont give you async programming capabilities.You need a library that actually wraps generators into coroutines,and then wrap async functions into "thunks" to make it work.
yes generators can help you control the flow as you do async programing, but you can't use generators to do something like an ajax function which gives you an async value, you'd need promises or something for that, generators allow you do use those async function is a more natural way.
Promises _are_ an async value. By yielding promises you're doing exactly that :)