Created
March 7, 2014 19:57
-
-
Save airportyh/9418744 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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