Skip to content

Instantly share code, notes, and snippets.

@hughfdjackson
Forked from anonymous/gist:1266473
Created October 6, 2011 04:04
Show Gist options
  • Save hughfdjackson/1266494 to your computer and use it in GitHub Desktop.
Save hughfdjackson/1266494 to your computer and use it in GitHub Desktop.
omatase_ - pastebin.com/DSaZDqvG
{
publishers: {},
fire: function (event) {
for (var i = 0; i < this.publishers[this.uid][event].length; i++) {
// call each listener's function
this.publishers[this.uid][event][i].listener[this.publishers[this.uid][event][i].func]();
}
},
addListener: function (uid, listener, func, event) {
if (!this.publishers[uid]) {
this.publishers[uid] = {};
}
if (!this.publishers[uid][event] || typeof (this.publishers[uid][event]) !== "array") {
this.publishers[uid][event] = [];
}
this.publishers[uid][event].push({ listener: listener, func: func });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment