Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is a very interesting idea. Although I still prefer the "jquery" way of passing in success/ failure as options. In fact, depending on what framework I'm using, I even trigger a success or failure event so it looks more like..

model.fetch();

model.on('error', function() { throw new Error(); });

But this article really got me thinking though, thank you!



The problem with passing success/failure as options is they don't compose well. Try to write the twitter example in the blog post this way. Then try to abstract each step as a reusable piece. And lastly have a mechanism for handling errors at any step. This looks ugly and is hard to follow. Promises (or generators) provide an API for thinking about async code as composable parts, which leads to easier to understand functions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: