primus / eventemitter3

EventEmitter3 - Because there's also a number 2. And we're faster.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`off` behaves differently than nodejs

uinz opened this issue · comments

commented

#262 mentioned that the on method is consistent with nodejs, but I found that the off method is inconsistent with nodejs.

{ "eventemitter3": "5.0.1" }
const ee = new EventEmitter()

ee.on('x', console.log)
ee.on('x', console.log)

ee.emit('x', 1) // print 1 twice

ee.off('x', console.log)


ee.emit('x', 1)
// expect: should print 1 once
// actual: no print

See

  • The removeListener method removes all matching listeners, not only the first.

off is an alias for removeListener.