Skip to content

Instantly share code, notes, and snippets.

@sporto
Created September 3, 2012 23:29
Show Gist options
  • Save sporto/3614806 to your computer and use it in GitHub Desktop.
Save sporto/3614806 to your computer and use it in GitHub Desktop.
Rivets adapter for CanJS
rivets.configure({
adapter: {
subscribe: function(obj, keypath, callback) {
callback.wrapped = function(ev, attr, how, newVal, oldVal) { callback(newVal) };
obj.bind('change', callback.wrapped);
},
unsubscribe: function(obj, keypath, callback) {
obj.unbind('change', callback.wrapped);
},
read: function(obj, keypath) {
return obj.attr(keypath);
},
publish: function(obj, keypath, value) {
obj.attr(keypath, value);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment