MatthewMueller/aemitter — pull request #1 by sukima (2014-04-08 01:09:27+00:00)
Title: Fix context of event callbacks

The context was being set inside a forEach function which will set the `this` context to global (`window` / `global`). Since this is designed to be applied to an object that object should be the context and not the global.

This will properly set the context. Includes specs.

Example:

function callback(e) {
console.log(this.foo); // => 'bar'
console.log(e); // => 'foobar'
}

function MyObj() {
this.foo = 'bar';
}

Emitter(MyObj.prototype);

new MyObj()
.on('foo', callback)
.emit('foo', 'foobar');