|
|
|
|
|
by Sephr
4856 days ago
|
|
I made a library called async.js (https://github.com/eligrey/async.js) that makes it even easier to abstract away all callbacks with yields, so all you'd have to do is yield to.sleep(5); continueFun(); for your example. More complex things are also easy to do as well, such as implementing a node.next(event) method, so you can simply do var click = yield document.next("click"); instead of the whole event listener shebang. The feedback example (https://github.com/eligrey/async.js#asking-the-user-for-thei...) shows how much of a difference using yield can be versus callbacks or even promises. |
|