A promise that resolves after a delay.

Domenic Denicola d at domenic.me
Wed Feb 3 20:55:53 UTC 2016

I think this is a reasonable API, but ES is not the spec for it. ES does not have a proper concept of an event loop, and definitely not a proper concept of time. Note that setTimeout is not defined in ES, but instead in HTML: https://html.spec.whatwg.org/#dom-windowtimers-settimeout

It might be worth proposing this at https://github.com/whatwg/html/issues; the form would probably be a new global function.

However, the biggest problem with such proposals is that they lack a way to clear the timeout. That is waiting for cancelable promises to arrive, which I am working on but I anticipate being contentious due to many differing opinions on the best way to do them.

So my best guess is that if you did propose this to HTML people would shout it down on the basis of not being able to cancel the timeout, and you'd have to wait until we figure out cancelable promises. But it's probably worth trying anyway.

More information about the es-discuss mailing list