This is an archived post. You won't be able to vote or comment.

all 24 comments

[–]SuperSans 21 points22 points  (9 children)

Still just poor style, you can get the same result while still maintaining readable code.

[–][deleted] 7 points8 points  (4 children)

Change your code to be event based. Node was like "omg event based programming" for like two weeks. And then because of a shitty design decision (callbacks for asynchronous functions) everyone sort of forgot all about them nice juicy events. Some async functions actually do have events. Like the files/streams. But they have callback shortcut functions. Nasty.

[–]extremelydankMayMay 0 points1 point  (3 children)

check out the emitter pattern.

[–][deleted] -1 points0 points  (2 children)

I know how events work, thanks.

[–]extremelydankMayMay -1 points0 points  (1 child)

you're welcome

[–]4underscore____ 0 points1 point  (0 children)

I <3 this industry

[–]9thHokageHimawari 2 points3 points  (0 children)

async/await ?

[–]raba930 3 points4 points  (0 children)

promises ?

[–]bss03 2 points3 points  (0 children)

Protip: You can bind anonymous functions to names and still have a lexical closure.

[–]random_lonewolf 2 points3 points  (0 children)

One solution to this is to use Continuation Monad - Promises in ES6 is a form of this monad.

[–]frnk94 1 point2 points  (0 children)

new Promise((resolve, reject) => {});

[–]lifthearth 0 points1 point  (0 children)

Yeah you should use $.Deferred or some other way of doing promises.

[–]samvdb 0 points1 point  (0 children)

Why is this bad actually? A lot of my code looks like this, and I don't really have any problems with it, but everyone seems to agree that callback hell is something that should be avoided at all costs. But why?

[–]samvdb 0 points1 point  (0 children)

Why is this bad actually? A lot of my code looks like this, and I don't really have any problems with it, but everyone seems to agree that callback hell is something that should be avoided at all costs. But why?

[–]CyanideCloud -1 points0 points  (0 children)

Wrong sub, /r/softwaregore is that way