Created
October 1, 2013 08:54
-
-
Save gurdotan/6775663 to your computer and use it in GitHub Desktop.
Backbone.Collection#fetchSingle - only one request in the air at a time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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