<div dir="ltr"><div><div><div><div>Depends where the object comes from is and who's setting it!<br><br>Couldn't you fire an event when the object is created, then do whatever work you need to do in the event listener ?<br>
<br></div>Alternatively, can "someObject" be an object inside "otherObject", for example, otherObject.someObject.<br><br></div>If you have it that way, you can write a setter/getter on "otherObject" for someObject. When someone does "otherObject.someObject = new Object();" your setter function gets called with the new value.<br>
<br></div>Either is preferable to the busy loop approach if you can do it.<br><br></div>Rik.<br><br><br><div class="gmail_extra"><br clear="all"><div>Rik Sagar, San Jose, CA 95124<br>Visit : <a href="http://sagar.org/" target="_blank">http://sagar.org/</a> <br>
</div><br><br><div class="gmail_quote">On Thu, May 22, 2014 at 10:32 AM, Larry Martell <span dir="ltr"><<a href="mailto:larry.martell@gmail.com" target="_blank">larry.martell@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I need to do the equivalent of this in javascript:<br>
<br>
while (typeof someObject == 'undefined') {<br>
sleep(10); // 10ms<br>
}<br>
<br>
And I just can't quite figure out how to code this.<br>
<br>
I have this:<br>
<br>
<br>
function sleep(ms, callback, arg) {<br>
setTimeout(function() {<br>
callback(arg);<br>
}, ms);<br>
}<br>
<br>
function waitForDef(elem) {<br>
if (typeof elem == 'undefined') {<br>
sleep(10, waitForDef, elem)<br>
}<br>
}<br>
<br>
But it's not clear to me how to use this from my code.<br>
_______________________________________________<br>
Help mailing list<br>
<a href="mailto:Help@lists.whatwg.org">Help@lists.whatwg.org</a><br>
<a href="http://lists.whatwg.org/listinfo.cgi/help-whatwg.org" target="_blank">http://lists.whatwg.org/listinfo.cgi/help-whatwg.org</a><br>
</blockquote></div><br></div></div>