Skip to content

Instantly share code, notes, and snippets.

@detj
Created December 7, 2012 10:50
Show Gist options
  • Save detj/4232460 to your computer and use it in GitHub Desktop.
Save detj/4232460 to your computer and use it in GitHub Desktop.
Piping Backbone Methods
;(function() {
var _fetch = Backbone.Collection.prototype.fetch;
var _reset = Backbone.Collection.prototype.reset;
_.extend(Backbone.Collection.prototype, {
fetching: false
});
Backbone.Collection.prototype.fetch = function(options) {
this.fetching = true;
console.log('Fetching on');
_fetch.call(this, options);
}
Backbone.Collection.prototype.reset = function(model, options) {
if (this.fetching) this.fetching = false;
console.log('Fetching off');
_reset.apply(this, [model, options]);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment