component/emitter — pull request #10 by MatthewMueller (2012-10-21 00:59:59+00:00)
Title: Allows you to just use Emitter.call(this) to perform the mixin

I have a feeling you guys have thought about this a lot more than I have but I think you can get the job done in a single command.

**Constructor:**

function List() {
if(!(this instanceof List)) return new List;
Emitter.call(this);
this.items = {};
this.el = $('

');
}

**Example:**

var List = require('list');

// First List
var list = new List;

list.add('hello from list');
list.el.appendTo('body');
list.on('select', function(slug) {
console.log('1', slug);
});
list.on('customEvent', function() {
console.log('aww yea');
})

// Second List

list2 = new List;
list2.add('hello from list2');
list2.el.appendTo('body')
list2.on('select', function(slug) {
console.log('2', slug);
});

// Event Tests

list.listeners('select') // [ fn() { console.log("1", slug) } ]
list.listeners('select') // [ fn() { console.log("2", slug) } ]

list.emit('customEvent') // aww yea
list2.emit('customEvent') // silent...