public
Created

Backbone.EventBinder

  • Download Gist
1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
doStuff = {
 
start: function(a, b, c){
this.events = new Backbone.EventBinder();
 
this.events.bindTo(a, "foo", this.doSomething, this);
this.events.bindTo(b, "bar", this.anotherThing, this);
this.events.bindTo(c, "baz", this.whatever, this);
},
 
doSomething: function(){ /* ... */ },
anotherThing: function(){ /* ... */ },
whatever: function(){ /* ... */ },
 
stop: function(){
this.events.unbindAll();
}
 
}
 
doStuff.start(ObjA, ObjB, ObjC);
 
// ... some time later in the code, stop it
 
doStuff.stop();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.