Awesome
events2
ES2015 implementation of nodejs EventEmitter
Installation
npm install events2
Run Tests
npm test
What's different from core EventEmitter?
-
emitter.off([eventName, listener])
methodThis is an alias for core
emitter.removeListener
ANDemitter.removeAllListeners
.emitter.off() // same as emitter.removeAllListeners() emitter.off('event') // removes all listeners of 'event' emitter.off('event', myListener) // removes myListener of 'event'
-
no
defaultMaxListeners
limit -
as a result – no
getMaxListners()
/setMaxListeners()
-
no
listeners()
andlistenersCount()
Notes
As event listeners storage is a Set()
, if you add same listener for same 'event'
repeatedly, listener will be called only once after 'event'
was emited (listener will be called as many times as it was added in nodejs core EventEmitter)