Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const EventEmitter = require('events');
const myEmitter = new EventEmitter();
function handler1() {
console.log('first handler');
myEmitter.removeListener('event', handler2);
}
function handler2() {
console.log('second handler');
}
myEmitter.on('event', handler1);
myEmitter.on('event', handler2);
myEmitter.emit('event');
myEmitter.emit('event');
// EXPECTED
// first handler
// first handler
// ACTUAL
// first handler
// second handler
// first handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.