Skip to content

Instantly share code, notes, and snippets.

@gurdotan
Created October 1, 2013 08:54
Show Gist options
  • Save gurdotan/6775663 to your computer and use it in GitHub Desktop.
Save gurdotan/6775663 to your computer and use it in GitHub Desktop.
Backbone.Collection#fetchSingle - only one request in the air at a time
var MyCollection = Backbone.Collection.extend({
fetchSingle : function() {
if (this.currentFetch && this.currentFetch.state() === "pending") this.currentFetch.abort();
this.currentFetch = this.fetch.apply(this, _.toArray(arguments));
return this.currentFetch;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment