Skip to main content

waitForNextExecutionContext

@combeenation/custom-code-utils


Function: waitForNextExecutionContext()

waitForNextExecutionContext(): Promise<void>

Asnychronous function for waiting until the JavaScript call stack is empty.
Can be used to wait for the shortest possible amount of time after the current execution context has been finished.

Example:

// Add some DOM element via JS and set some CSS
await AsyncUtils.waitForNextExecutionContext(); // Let the browser actually render the DOM element
// Ask browser for rendered size of the newly created DOM element

Returns

Promise<void>