mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-13 14:05:27 +00:00
update
This commit is contained in:
42
node_modules/emitter-mixin/Readme.md
generated
vendored
Normal file
42
node_modules/emitter-mixin/Readme.md
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
[Node](https://nodejs.org) EventEmitter mixin.
|
||||
|
||||
## Example
|
||||
|
||||
```javascript
|
||||
|
||||
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.
|
||||
|
||||
```javascript
|
||||
emitter(Person.prototype);
|
||||
var person = new Person();
|
||||
person._events == person._events;
|
||||
// > true
|
||||
person._events == Person.prototype._events;
|
||||
// > false
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
```bash
|
||||
$ make test
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(MIT)
|
Reference in New Issue
Block a user