listeners

 const events = require('events');

const e = new events.EventEmitter();

e.setMaxListeners(4);

//===========Example1
e.on('event1',function () {
console.log('event1');
})
e.on('event1',function () {
console.log('event2');
})
e.on('event1',function () {
console.log('event3');
})
e.on('event1',function () {
console.log('event4');
})

//==============call
//e.emit('event1');

//i want output Like
//event1
//event3
let a=e.listeners('event1');

a.forEach((item,index)=>{

if (index === 0 || index === 2) {
item(); // 👉 This actually CALLS the function
}
})

Comments

Popular posts from this blog

App 1st User Define Component

Example 1

Rabiit