2 ms·
"The problem is that you end up nesting a lot." I haven't done that much of asynchronous programming, but I think you end up creating some helper constructs th
by Tichy 17y ago
"The problem is that you end up nesting a lot."
I haven't done that much of asynchronous programming, but I think you end up creating some helper constructs that help prevent excessive nesting. For example you could create a function that takes an array of functions and calls them sequentially (in the sense that when the first callback is executed, it calls the second function and so on).
- swannodette 17y agoYou can't get around nesting if functions take a callback in their interface. It's viral. You can mitigate _some_ of these problems by defining a custom event system, but this makes code logic very hard to follow. It's better in a complex system to hide the mechanism altogether. A little higher on the thread I point out that this can be done by custom events and function decoration.