// Wait for this function to return true
return (v1 == 100);
// ... and then do this
v2 = true;
// ... unless the waiting is so long
v3 = false;
// ... as 10000 ms.
This library exports a function called 'wait'. It aims to simplify the
standard setInterval-clearInterval pattern which is used to ensure the
synchronous of data.
especially when you're dealing with cross browser issue. Sometimes the
returned object of "document.createElement('div')" may not have it's
".style" property ready when you want to use it.
So here's what 'wait' does: It keeps checking whether a given etst
passed or not periodically. Once the test passed, call the callabck. If
the waiting time is too long, longer then the maximum, another failure
callback is called.
The 'wait' function can be used in two form: either with 3 arguments or
4 arguments. The semantic of its 3-argument form is:
wait(test, callback, max_wait)
And for its 4-argument form, it would be:
wait(test, callback, failure_callback, max_wait)
It handles "setInterval()" and calls "clearInterval()" once the test
passed, or elapsed over max waiting time. You may omit the last
"max_wait" argument, in such case it never ends waiting, which means the
"failure_callback" would never be called even if it's given. So you
might just use this form for convienence:
Waiting indefinitely might not be the best behaviour, but long as you
can ensure that the test would be passing, it's golden.
Kang-min Liu <firstname.lastname@example.org>.
Copyright 2006, 2007, 2008, 2009 by Kang-min Liu <email@example.com>.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.