Skip to content

Instantly share code, notes, and snippets.

@airportyh
Created March 7, 2014 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save airportyh/9418744 to your computer and use it in GitHub Desktop.
Save airportyh/9418744 to your computer and use it in GitHub Desktop.
function BackboneAdapter(model){
if (!(this instanceof BackboneAdapter)) return new BackboneAdapter(model);
this.model = model;
}
BackboneAdapter.prototype = {
subscribe: function(prop, fn){
this.model.on('change:' + prop, fn);
},
unsubscribe: function(prop, fn){
this.model.off('change:' + prop, fn);
},
unsubscribeAll: function(){
this.model.off();
},
set: function(prop, value){
this.model.set(prop, value);
},
get: function(prop, value){
return this.model.get(prop);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment