Skip to content

Instantly share code, notes, and snippets.

@aarondai
Created July 25, 2014 16:42
Show Gist options
  • Save aarondai/140c1cc49f1bd2e6d28e to your computer and use it in GitHub Desktop.
Save aarondai/140c1cc49f1bd2e6d28e to your computer and use it in GitHub Desktop.
JavaScript:Wait for variable
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