Skip to content

Instantly share code, notes, and snippets.

@thejefflarson
Created October 7, 2010 15:52
Show Gist options
  • Save thejefflarson/615332 to your computer and use it in GitHub Desktop.
Save thejefflarson/615332 to your computer and use it in GitHub Desktop.
var events = {
e : {},
register : function(key, fn) {
this.e[key] = fn;
},
trigger : function(key){
try {
this.e[key]();
} catch(e) {
if(key != "error")
this.trigger("error")
}
}
}
events.register("err", function(){
throw "new error";
});
events.register("error", function(){
console.log("caught an error");
});
events.trigger("err");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment