News for hackers. Stuff that matters.
Re:Fixing the callback spaghetti in node.js by gfxmonk on Thursday September 29, 2011 @08:56AM (#3052241)
Imagine function a calls b() and function b calls c(), and they're all sync.

Now, let's say c() changes and needs to call someAsyncFunction() and provide a callback. Which means c itself needs to take a callback. Which means b needs to provide a callback, so b needs to also take a callback, so a needs to provide a callback. And so forth.

Callbacks are infectious - once anybody in the call stack needs one, everybody needs one even if they just pass it on down the stack. Unless you don't need to do anything with return values, but that's fairly rare.

There are no comments on this comment yet.