I don't understand how the function(msg)...
is called with myEmmiter.emit
.
How does the .emit('someEvent', ...)
know that the argument 'the event was emitted'
should be passed to function(msg)...
?
Is there a way to see the emit
method source?
const events = require('events');
var myEmmiter = new events.EventEmitter();
myEmmiter.on('someEvent', function (msg) {
console.log(msg);
});
myEmmiter.emit('someEvent', 'the event was emitted');
via rafr3
No comments:
Post a Comment