Skip to content

Instantly share code, notes, and snippets.

@paulmand3l
Created December 18, 2013 02:11
Show Gist options
  • Save paulmand3l/8016250 to your computer and use it in GitHub Desktop.
Save paulmand3l/8016250 to your computer and use it in GitHub Desktop.
Promise Retry Pattern
doThisUntilItWorks = () ->
doSomethingAsync().then (result) ->
doSomething result
, (reason) ->
console.warn "Retrying"
deferred = Q.deferred()
setTimeout (->
deferred.resolve(doThisUntilItWorks())
), retryDelay
deferred.promise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment