Created
July 25, 2014 16:42
-
-
Save aarondai/140c1cc49f1bd2e6d28e to your computer and use it in GitHub Desktop.
JavaScript:Wait for variable
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 something=999; | |
var something_cachedValue=something; | |
function doStuff() { | |
if(something===something_cachedValue) {//we want it to match | |
setTimeout(doStuff, 50);//wait 50 millisecnds then recheck | |
return; | |
} | |
something_cachedValue=something; | |
//real action | |
} | |
doStuff(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment