Add new function waitFor

Naveen Chawla naveen.chwl at gmail.com
Thu Nov 16 12:21:21 UTC 2017


Wouldn't it be more useful to have an async `delay(milliseconds)` function,
which simply takes a number (as an alternative to setTimeout), instead of
having to pass in a function whose code is executed and then the code after
it??? I have suggested that here before, but it happens to be a browser
spec feature thing, not a core language thing (at least not yet) - since
setTimeout itself is not yet in the core language, as far as I know

On Thu, 16 Nov 2017 at 16:50 Eugene Melnikov <
melnikaite.melnikaite at gmail.com> wrote:

> It’d be great to see native implementation of `waitFor` function. This
> function is used a lot in test frameworks and sometimes it’s necessary to
> wait something via polling. The syntax should be `await
> waitFor(function/primitives, timeout)`. Once function in first argument
> return anything except `false`, `null` or `undefined` next line of code
> will be executed. Second argument means period of time in ms to run
> function from first argument. Returned value of `waitFor` will be forwarded
> from executed function. In case first argument if primitive the first
> argument will be returned after delay specified in second argument. So it
> will be easy to make simple delay `async waitFor(true, 1000)` instead of
> `await new Promise(r => setTimeout(r, 1000))`.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171116/94b825e1/attachment.html>


More information about the es-discuss mailing list