Created
August 27, 2015 14:00
-
-
Save Andygmb/6cb27ba326695efe7ffc to your computer and use it in GitHub Desktop.
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
function retry(retries, assertion, timeout, callbackSuccess, callbackFailure){ | |
var i = 0; | |
function _retry() { | |
i++; | |
if (assertion) { | |
callbackSuccess(); | |
} else { | |
if (i < retries) { | |
setTimeout(_retry, timeout); | |
} else if (callbackFailure != undefined & i > retries) { | |
callbackFailure(); | |
} | |
} | |
} | |
_retry() | |
} | |
var assertion = function(){FB.length > 0} | |
var callbackFailure = function(){displayError(".fb-messages-box", "An error occurred", "Could not set up Facebook SDK.");} | |
retry(4, assertion, 500, get_fb_pages, callbackFailure) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment