denisw/buddycloud-http-client — pull request #5 by rodrigods (2012-09-07 00:44:57+00:00)
Title: (Un)follow a channel

Here are the needed modifications.

To POST only changed attributes, the sync method at SubscribedChannels.js was override:

subscribe: function(channel, node) {
this.set(channel + '/' + node, 'publisher', {silent: true});
this.save();
},

unsubscribe: function(channel, node) {
this.set(channel + '/' + node, 'none', {silent: true});
this.save();
},

sync: function(method, model, options) {
if (method === 'update' || method === 'create') {
// always POST only changed attributes
var changed = model.changedAttributes();
if (changed) {
options.data = JSON.stringify(changed || {});
method = 'create';
}
}

Backbone.sync.call(this, method, model, options);
}