Listen to All Emitted Events in Node.js

后端 未结 12 1297
孤街浪徒
孤街浪徒 2020-12-24 00:06

In Node.js is there any way to listen to all events emitted by an EventEmitter object?

e.g., can you do something like...

event_emitter.on(\         


        
12条回答
  •  感情败类
    2020-12-24 00:46

    You can also use another event emitter implementation like https://github.com/ozantunca/DispatcherJS. The implementation would be like:

    dispatcher.on('*', function () {});
    

    DispatcherJS also supports namespaces and even dependencies to determine which callbacks are going to be called first.

提交回复
热议问题