2

I've been using Nodejs and I really dislike callbacks (as i think most people do.) I'm starting to learn about promises and generators. Both are a lot cleaner and I'd like to forget the horrors of callbacks all together and erase them from my memory.

Is there any reason I need to use callbacks. Can I completely abandon them and use promises or generators instead of them and never need to write another callback? Or do they have some use case where they are needed?

2
  • 4
    Promises will be a lot, lot cleaner than plain callbacks. But, keep in mind that promises work via callbacks too, they just offer you a lot more functionality and structure for use with those callbacks.
    – jfriend00
    Commented Jun 11, 2015 at 23:02
  • 1
    Could the reopen voter please leave a comment explaining why they believe this should be reopened? (I don't have anything against this question, I just honestly can't think of any reason to reopen it)
    – Ixrec
    Commented Nov 15, 2015 at 13:28

1 Answer 1

2

The short answer is yes, you can pretty much replace callbacks with promises. The caveat is some library APIs use callbacks so you are unlikely to be able to avoid them altogether.

Not the answer you're looking for? Browse other questions tagged or ask your own question.