kai zhu has a good example of solving async order problems explicitly, as opposed to banking on any defer or timeout to figure it out.
I'm a little curious of what you mean by "something that cannot run immediately". If it can't be run immediately, then there should be *something* you can hook into to run -- otherwise you're playing guesswork on what is currently scheduled to execute. Examples of the arbitrary use of "setTimeout" to defer to another script frame in the DOM is when a frontend framework hasn't created elements yet, and you need to run a query selector to grab them, or similar shenanigans. I'd argue more that these are all anti patterns, since why should you be guaranteed that toDoLater() can even be run after the setTimeout(1) or when the Promise scheduler runs?
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss