UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

23 lines 1.07 kB
/** * Yield the current task back to the browser so it can paint and process input * before the awaited continuation runs. * * Uses `scheduler.yield()` when available (modern Chromium) for better priority * handling; falls back to `setTimeout(_, 0)`, which macrotask-defers in every * browser, in Node/SSR, and in fake-timer test environments. */ export declare function yieldToMain(): Promise<void>; /** * Run `task` during the browser's first idle period, falling back to * `setTimeout(task, 0)` where `requestIdleCallback` is unavailable (Safari, * Node/SSR, fake timers). Use this for genuinely deferrable background work * (e.g. stale-while-revalidate refreshes, the `idle` highlight/enhance swap) * that should wait for the main thread to be free. * * @param options.timeout forwarded to `requestIdleCallback` so the task still * runs even if the browser never goes idle. * @returns a function that cancels the task if it has not run yet. */ export declare function requestIdle(task: () => void, options?: { timeout?: number; }): () => void;