Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can yield back to the UI event loop in an async function through

   await new Promise((resolve) => setImmediate(resolve))
or similar constructs using setTimeout or requestAnimationFrame


Correct.

Though setImmediate is specific to IE/Edge.

    setTimeout(resolve, 0)
will allow any queued events/macrotasks to occur, and then immediately resolve.

    requireAnimationFrame(resolve)
will wait until the browser is ready to render another frame, and then resolve.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: