-
-
Save adambankin/e36f670bb3534e1bda65fe5e153db157 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var initializationPromise = utilsAsync.makePromise(function (resolve, reject) { | |
checkPendo(); | |
function checkPendo () { | |
var delay = 0; | |
if (window.pendo === undefined) { | |
if (delay < 8) { | |
setTimeout(checkPendo, (delay = Math.max(delay *= 2, 1)) * 1000); | |
} else { | |
// TODO: handle failure(?) | |
console.warn('pendo did not load'); | |
reject(new Error("pendo did not load")); | |
} | |
} else { | |
resolve(window.pendo); | |
} | |
} | |
}); | |
// or | |
var initializationPromise = utilsAsync.makePromise(function (resolve, reject) { | |
var counter = 0; | |
function checkPendo () { | |
if (window.pendo === undefined) { | |
if (counter < 8) { | |
counter++; | |
setTimeout(checkPendo, 1000); | |
} | |
} else { | |
resolve(window.pendo); | |
} | |
} | |
checkPendo(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment