work.suroh.tk/node_modules/emitter-mixin
suroh 410082595a init 11ty commit 2019-12-02 13:22:45 +01:00
..
test init 11ty commit 2019-12-02 13:22:45 +01:00
History.md init 11ty commit 2019-12-02 13:22:45 +01:00
Makefile init 11ty commit 2019-12-02 13:22:45 +01:00
Readme.md init 11ty commit 2019-12-02 13:22:45 +01:00
index.js init 11ty commit 2019-12-02 13:22:45 +01:00
package.json init 11ty commit 2019-12-02 13:22:45 +01:00

Readme.md

Node EventEmitter mixin.

Example


var emitter = require('emitter-mixin');

function Person () {}
emitter(Person.prototype);

var person = new Person();
person.on('foo', function (arg) {
  console.log(arg);
}).emit('foo', 'bar');

// > bar

You don't have to do Emitter.call(this) in your constructor anymore, the mixin defines an _events getter that does the magic for you.

emitter(Person.prototype);
var person = new Person();
person._events == person._events;
// > true
person._events == Person.prototype._events;
// > false

Tests

$ make test

License

(MIT)