Reputation: 4771
Which is the best practice to write nodejs code.
There are so many callback in my current code and reduced the readability.
Any suggestion?
Upvotes: 2
Views: 7060
Reputation: 201
Callback: Use a callback if you just want to execute some code at a certain time and you don't need to emit success or failure.
EventEmitter: Use this if your object emits lots of types of events.
Upvotes: 1
Reputation: 68453
Try to look at some flow control libraries and articles in answer to this question: Async programming paradigm with nodejs and redis-node.
Upvotes: 0