I've module like following which I want to emit event like this:
file aa.js
var EventEmitter = require("events").EventEmitter,
eventEmitterIns = new EventEmitter();
var preProcess = function (cb) {
...
var start = function () {
....
}).catch(function (err) {
//-------------HERE I EMIT THE EVENT-----------
eventEmitterIns.emit('test');
}
}
}
module.exports = {
preProcess: preProcess,
eventEmitterIns: eventEmitterIns
};
Now I want in other module to catch this error event when I do the following it doesn't work for me:
bb.js
var invokeAppEvents = require('../controller/aa');
invokeAppEvents.eventEmitterIns.on('test', function () {
debugger;
}
);
If I put breakpoint it doesn't stops in the debugger; how can I overcome this?
The Code inside the catch block is called!
What should I export in aa.js and what should I require in bb.js?