emitter-mixin

0.0.3 • Public • Published

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)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.3
    27,094
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.3
    27,094
  • 0.0.1
    0

Package Sidebar

Install

npm i emitter-mixin

Weekly Downloads

27,094

Version

0.0.3

License

MIT

Last publish

Collaborators

  • yields