primus / eventemitter3

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onAny and onceAny

DevoidCoding opened this issue · comments

Hi ! I wanna add two functions to the actual EventEmitter, onAny and onceAny.

onAny(events, fn, context)

This function will take an array of events, the listener function and a context. Basically, it's just a loop over the events' array calling the actual function addListener to register the events.

onceAny(events, fn, context)

Same arguments as above. This function will call the listener only once - and unregister the listener of the events' array, no matter which one, as long as it's in the events's array.

Both functions will call fn with the first argument being the event who got emit.

I prefer to not add these methods to keep the library size as small as possible.
You can extend the exported class with custom features if you want.