mirror of
https://git.unlock-music.dev/um/um-react.git
synced 2024-11-24 08:12:16 +00:00
12 lines
376 B
TypeScript
12 lines
376 B
TypeScript
|
type NextTickFn = (callback: () => void) => void;
|
||
|
const nextTickFn =
|
||
|
typeof setImmediate !== 'undefined'
|
||
|
? (setImmediate as NextTickFn)
|
||
|
: typeof requestAnimationFrame !== 'undefined'
|
||
|
? (requestAnimationFrame as NextTickFn)
|
||
|
: (setTimeout as NextTickFn);
|
||
|
|
||
|
export async function nextTickAsync() {
|
||
|
return new Promise<void>((resolve) => nextTickFn(resolve));
|
||
|
}
|