Monday, 8 October 2018

node.js: emitter.rawListeners(eventName)

emitter.rawListeners(eventName)
This method returns a copy of the array of listeners for the event named eventName.

HelloWorld.js
var EventEmitter = require('events').EventEmitter;

var emitter = new EventEmitter();

var goodMorning = () => {
 console.log('Good Morning');
}

var welcome = () => {
 console.log('Welcome to node.js programming');
}

emitter.on('hello', goodMorning);
emitter.on('hello', welcome);

var listeners = emitter.rawListeners('hello');

for(index in listeners){
 console.log(listeners[index]);
}


Output

[Function: goodMorning]
[Function: welcome]




Previous                                                 Next                                                 Home

No comments:

Post a Comment