Basic event emitter
A simple event emitter. I implemented my own so I could optimise for performance and implement new features as I require. The main advantage of this implementation is its handling of context. It allows you to specify a context when you create a subscription (a la backbone.js) but also takes this into account when unsubscribing. So when unsubscribing you have three levels of specificity available to you. topic(s), topic(s)+callback, and topic(s)+callback+context. This makes it possible to work with methods defined on an objects prototype without wrapping them since you now have a way of differentiating between subscriptions belonging to different instances.
$ component install jkroso/emitter
$ npm install jkroso/emitter
Generate an instance of Emitter
var emitter =
An alternative constructor syntax
Add emitter behavior to any object
Generate an event
Add a subscription under a topic name
Add the subscription but insure it never called more than once
emitter // clears all topicsemitter // clears all handlers under 'topic'emitter // removes fn from 'topic'emitter // removes fn from 'topic' with context of `window`
Copyright (c) 2012 Jakeb Rosoman
Licensed under the MIT license.