nodejs event emitter instance code example
Example 1: event module in node js
const myEmitter = new MyEmitter();
let m = 0;
myEmitter.on('event', () => {
console.log(++m);
});
myEmitter.emit('event');
// Prints: 1
myEmitter.emit('event');
// Prints: 2
Example 2: eventemitter nodejs
myEmitter.on('status', (code, msg)=> console.log(`Got ${code} and ${msg}`));