Last active
December 17, 2015 17:39
-
-
Save vancouverwill/5647118 to your computer and use it in GitHub Desktop.
multi level interval boolean check with timeout
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 successFunction() { | |
console.log('begin nike button'); | |
} | |
function failFunction() { | |
console.log('shit hit the fan'); | |
} | |
function setTimedOutInterval(totalTime, intervalTime, callBackFunction) { | |
var args = Array.prototype.slice.call(arguments, 3); | |
console.log(arguments); | |
console.log(totalTime); | |
var tmpDelayB = setTimeout(function () { | |
clearInterval(intervalId); | |
console.log('function over'); | |
callBackFunction.apply(null, args); | |
}, totalTime); | |
var intervalId = setInterval(function () { | |
console.log('check '); | |
if (finished === true) { | |
console.log('B finished = true'); | |
clearInterval(intervalId); | |
clearTimeout(tmpDelayB) | |
successFunction(); | |
} | |
}, intervalTime); | |
} | |
var finished = false | |
var sdkDelay = setTimeout(function () { | |
console.log('done'); | |
finished = true; | |
}, 10000); | |
setTimedOutInterval(4000, 100, setTimedOutInterval, 10000, 1000, failFunction); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment