Skip to content

Instantly share code, notes, and snippets.

@randallb
Created June 8, 2012 17:14
Show Gist options
  • Save randallb/2896943 to your computer and use it in GitHub Desktop.
Save randallb/2896943 to your computer and use it in GitHub Desktop.
Backbone fetch limiting.
#define @fetch in your initializer.
fetch: (options) ->
options.success = =>
@fetching[@url] = undefined
options.error = =>
@fetching[@url] = undefined
if JSON.stringify(@fetching[@url]) == JSON.stringify(options)
console.log "old fetch in progress for #{@url}"
else
console.log "Going to fetch for #{@url}"
@fetching[@url] = options
super options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment