µ-emitter.js
A micro emitter with pluggable executor
Mikael Karon <
mikael.karon@ef.com>
EF Labs (Shanghai)
EF Labs (Shanghai)
Emitter: What is it?
- Devices which emit charged particles
- Devices which emit electromagnetic radiation
- Emitter, a device used in drip irrigation
That's not what I was looking for...
Emitter: what it is!
Sort of kind of like the node API
emitter.on(event, listener)
emitter.once(event, listener)
emitter.off(event, listener)
emitter.emit(event[, arg1][, arg2][, ...])
So what's different?
- List based subscriptions
- Custom emission executors
List what?
Why on earth would you not use arrays?
- Faster when modifying in the middle
- A lot faster in older engines
- Probably yields better memory usage
Custom executor WTF bbq?
What can I do with it?
- Passing same arguments to all subscribers
- Passing the result from the previous subscriber to the next one
- Filter subscribers during emission
- Make subscribers async!
- Implement other side effects (such as count limit)
Questions?
µ-emitter
By Mikael Karon
µ-emitter
- 628