yield
Dominic Gannaway 9 months ago
parent 30bf2f68f0
commit 3430305bd6

@ -12,7 +12,12 @@ export const request_idle_callback =
export const schedule_yield =
// @ts-ignore
typeof scheduler === 'undefined'
? (/** @type {() => void} */ cb) => setTimeout(cb, 1)
? (/** @type {() => void} */ cb) => {
// For Safari, we fallback to using MessageChannel
const channel = new MessageChannel();
channel.port1.onmessage = cb;
channel.port2.postMessage(undefined);
}
: async (/** @type {() => void} */ fn) => {
// @ts-ignore
await scheduler.yield();

Loading…
Cancel
Save