-
Notifications
You must be signed in to change notification settings - Fork 310
Adapters
pgib edited this page Jan 3, 2015
·
14 revisions
Directory of Rivets.js adapters with compatibility tables for common libraries and frameworks.
rivets.configure({
adapter: {
observe: function(obj, keypath, callback) {
obj.on("change:" + keypath, callback)
},
unobserve: function(obj, keypath, callback) {
obj.off("change:" + keypath, callback)
},
get: function(obj, keypath) {
return obj.get(keypath)
},
set: function(obj, keypath, value) {
obj.set(keypath, value)
}
}
})
- https://github.com/azproduction/rivets-backbone-adapter (It supports rivets 0.6.5+)
- https://github.com/BBWeb/RBR/blob/master/rivets-backbone.js
rivets.configure({
adapter: {
observe: function(obj, keypath, callback) {
obj.bind('change', function(ev, attr, how, newVal, oldVal) {
callback(newVal)
})
},
unobserve: function(obj, keypath, callback) {
obj.unbind('change', callback)
},
get: function(obj, keypath) {
return obj.attr(keypath)
},
set: function(obj, keypath, value) {
obj.attr(keypath, value)
}
}
})
https://github.com/helgoboss/rivets-iota-observable-adapter
rivets.configure({
adapter: {
observe: function(obj, keypath, callback) {
watch(obj, keypath, callback)
},
unobserve: function(obj, keypath, callback) {
unwatch(obj, keypath, callback)
},
get: function(obj, keypath) {
return obj[keypath]
},
set: function(obj, keypath, value) {
obj[keypath] = value
}
}
})
Rivets adapter for Y.Model.
rivets.adapters[':'] = {
observe: function(obj, keypath, callback) {
return obj.afterHandle = obj.after(keypath + 'Change', callback);
},
unobserve: function(obj, keypath, callback) {
var _ref;
return (_ref = obj.afterHandle) != null ? _ref.detach() : void 0;
},
get: function(obj, keypath) {
return obj.get(keypath);
},
set: function(obj, keypath, value) {
return obj.set(keypath, value);
}
rivets.adapters[':'] =
observe: (obj, keypath, callback) ->
obj.afterHandle = obj.after(keypath + 'Change', callback)
unobserve: (obj, keypath, callback) ->
obj.afterHandle?.detach()
get: (obj, keypath) ->
obj.get(keypath)
set: (obj, keypath, value) ->
obj.set(keypath, value)