Scope of events from process.emit in Node.js

戏子无情 提交于 2019-12-11 05:12:56

问题


I have code to sent event like this:

process.emit('event', event);

I would like to listen to these event like this:

process.on('event', function(event) {
     //HANDLING LOGIC
});

It works fine when files are located in the same folder. When I located listener in other folder it is not fired. What can be a root cause of this and hwo can I handle it?

EDIT:

The actual problem was just a missing expose with a file including event handling. Shame on me.


回答1:


The process is a single global instance. the scope should not be related to your problem.

process in node.js docs



来源:https://stackoverflow.com/questions/43888777/scope-of-events-from-process-emit-in-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!