Created
December 18, 2013 02:11
-
-
Save paulmand3l/8016250 to your computer and use it in GitHub Desktop.
Promise Retry Pattern
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
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