(I don't like promises and would like to see it go away. Sadly too many specs have adopted it already)
(I don't like promises and would like to see it go away. Sadly too many specs have adopted it already)
You could always just... not use them.
If you're in favor or callbacks, you're doing it wrong.
I use promises and like them, but generators are a LOT nicer. I've been playing around with KoaJS and I'm amazed with it. I find that overall it makes code a lot easier to read, write, and understand.
On top of that, it give you sane stack-traces!
I'm not certain if this is correct, but from what I can gather, you can yield on a promise and if you resolve it successfully you get the value directly and if you resolve it as a failure, it will throw an error.
The example I like to show people is this: https://www.dropbox.com/s/06zy52m8x0lllzn/Screenshot%202014-... It's the controller for a user's registration, where the thrown error is an object of invalid fields submitted.