Define EventEmitter listeners on a class instead of each individual instance
Define EventEmitter listeners on a class to save on memory consumption in exchange for a little bit of extra work emitting the events themselves.
Suitable when you've got a lot of mostly similar EventEmitters, and you're not emitting enough events for it to be a performance bottleneck.
See also: bindle
Returns a new
prototype-emitter class. Optionally you can pass a
in as the first argument to mixin
Once created or mixed in, you can add event listeners directly on the
class before (or after) creating instances of it. These listeners will
be available on each instance, so calling
ee.emit will trigger these
var PrototypeEmitter = require'prototype-emitter'var CustomEmitter = PrototypeEmitterCustomEmitteronce'data'console.log'data recieved: 'CustomEmitteron'data'console.log'>>' datavar emitter =emitteron'data'console.log' >' dataemitteremit'data' 1emitteremit'data' 2emitteremit'data' 3// data recieved:// >> 1// > 1// >> 2// > 2// >> 3// > 3
MIT. See LICENSE.md for details.