6 ms·
Will promises still be needed with generators?
by jc123 12y ago
Will promises still be needed with generators?
- AgentME 12y agoThey work together very nicely. See taskjs (http://taskjs.org/ 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_functions http://wiki.ecmascript.org/doku.php?id=strawman:async_functi...).
- cwmma 12y agoyes 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.
- inglor 12y agoPromises _are_ an async value. By yielding promises you're doing exactly that :)
- aikah 12y agoGenerators 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.