4 ms·
What's being discussed wrt promises? (I don't like promises and would like to see it go away. Sadly too many specs have adopted it already)
by general_failure 12y ago
What's being discussed wrt promises?
(I don't like promises and would like to see it go away. Sadly too many specs have adopted it already)
- untog 12y agoI don't like promises and would like to see it go away You could always just... not use them.
- JohnBooty 12y agoMost coders have to use and extend a lot of other peoples' code, so if everybody else is using them then you have to deal with it...
- Kiro 12y agoWhat do you think is a better alternative?
- abjorn 12y agoThere are some very interesting things you can do with generators in regards to asynchronous flow control. Personally I'm in favor of the Promises, however. Unfortunately some current implementations are broken in terms of error handling. Chrome just swallows exceptions that happen in Promises, in a lot of cases.
- Touche 12y agoGenerators are no fun to work with so you want a library. Promises won't require a library so i'll use that.
- coldtea 12y agoWhy, what's the alternative? If you're thinking of using something like a generator, OK. If you're in favor or callbacks, you're doing it wrong.
- TheAceOfHearts 12y agoGenerators are the solution. 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-05-01%2014.59.22.png 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.