[html5] Waiting for an object to be defined in javascript
Larry Martell
larry.martell at gmail.com
Thu May 22 10:32:57 PDT 2014
I need to do the equivalent of this in javascript:
while (typeof someObject == 'undefined') {
sleep(10); // 10ms
}
And I just can't quite figure out how to code this.
I have this:
function sleep(ms, callback, arg) {
setTimeout(function() {
callback(arg);
}, ms);
}
function waitForDef(elem) {
if (typeof elem == 'undefined') {
sleep(10, waitForDef, elem)
}
}
But it's not clear to me how to use this from my code.
More information about the Help
mailing list