AsyncHelper
A helper class to make asynchronous tasks await friendly.
Functions
3
Functions
3animationFramestatic
Returns a promise that resolves on next animation frame.
async method() {
// do work
await AsyncHelper.animationFrame();
// do more work
}
sleepstatic
Returns a promise that resolves after a specified number of milliseconds.
async method() {
await AsyncHelper.sleep(10);
// ...
}
| Parameter | Type | Description |
|---|---|---|
millis | Number | The number of milliseconds to sleep. |
yieldstatic
Returns a promise that resolves as soon as possible, allowing the browser to minimally process other messages. This is the shortest possible delay the browser offers, so be aware that it does not necessarily allow the browser to paint or reflow if used in a long loop. It does, however, allow other async methods to execute.
async method() {
await AsyncHelper.yield();
// ...
}