emitter-mixin
Node's EventEmitter mixin
Last updated 12 years ago by yields .
MIT · Repository · Original npm · Tarball · package.json
$ npm install emitter-mixin 
SYNC missed versions from official npm registry.

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)

Current Tags

  • 0.0.3                                ...           latest (12 years ago)

2 Versions

  • 0.0.3                                ...           12 years ago
  • 0.0.1                                ...           12 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE