I_Jemin

Event Argument

Showing 1 changed file with 9 additions and 2 deletions
1 -const log = require('./logger') 1 +const EventEmitter = require('events');
2 +const emitter = new EventEmitter();
3 +
4 +// Register a listener
5 +emitter.on('messageLogged', function(arg) { // e, eventArg
6 + console.log('Listener called',arg);
7 +});
8 +
9 +emitter.emit('messageLogged', {id: 1, url: 'http://' });
2 10
3 11
4 -log('message');
...\ No newline at end of file ...\ No newline at end of file
......