开发者

Nodejs Callback or eventEmitter

开发者 https://www.devze.com 2023-03-27 21:55 出处:网络
Which is the best practice to write nodejs code. There are so many callback in my curr开发者_运维百科ent code and reduced the readability.

Which is the best practice to write nodejs code.

There are so many callback in my curr开发者_运维百科ent code and reduced the readability.

Any suggestion?


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.


Try to look at some flow control libraries and articles in answer to this question: Async programming paradigm with nodejs and redis-node.

0

精彩评论

暂无评论...
验证码 换一张
取 消