`off` behaves differently than nodejs
uinz opened this issue · comments
yinz 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
Luigi Pinca commented
See
- The
removeListener
method removes all matching listeners, not only the first.
off
is an alias for removeListener
.