Unusual Event-Emitter
Because I can. Because I like to use arrow functions in my event listeners. And I don't want to save each sh**ty function as a variable just to be able to remove the listener later. So I save it's ID instead!
extend
from it.
Nothing but ES6 Class. Feel free to Except for one little detail: The main feature is event-id
for each event.
const UEE = const ev = const event_id = ev // somewhere else in the universe// you want to unsubscribe from this specific eventev
That's it. Nothing to look at... :3
Oh, wait! Maybe also this... .emit()
returns number of fired events:
evev const howMuch = ev console // beeped: 2 times const whosThere = ev console // also output: 2
Nah... nevermind. Forget about it.
ev
NOTE:
- No tests.
- No dependencies.
- No mind-blowing features.
- No babel/ts/or-whatever.
Future
- Maybe some performance micro-optimizations will come later.
- I will use it.