Function queue_microtask

pub fn queue_microtask(task: impl FnOnce() + 'static)
Expand description

A microtask is a short function which will run after the current task has completed its work and when there is no other code waiting to be run before control of the execution context is returned to the browser’s event loop.

Microtasks are especially useful for libraries and frameworks that need to perform final cleanup or other just-before-rendering tasks.

MDN queueMicrotask

The task is called outside of the ownership tree, this means that if you want to access for example the context you need to reestablish the owner.