Skip to content

Instantly share code, notes, and snippets.

@fredsterss
Created February 7, 2013 21:12
Show Gist options
  • Save fredsterss/4734208 to your computer and use it in GitHub Desktop.
Save fredsterss/4734208 to your computer and use it in GitHub Desktop.
# backbone fetch + async lib helper method, automatically routes
# the callback from success/error to the async required callback
async.fetch = (model) ->
return (callback) ->
model.fetch
success: (model, response) ->
callback null, model
error: (model, xhr) ->
# process failure with errorhandler
r.app.errorHandler.handle(xhr)
callback xhr.responseText, model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment