onIdle
function
stablesince v22.0
A PrefetchTrigger helper function to provide the logic of triggering dependency loading
when the browser becomes idle.
@paramoptions
{ timeout?: number | undefined; } | undefined@returns
Promise<void>Description
A PrefetchTrigger helper function to provide the logic of triggering dependency loading
when the browser becomes idle.
Internally delegates to the configured IdleService, whose default implementation uses
requestIdleCallback
when available and falls back to setTimeout otherwise. The default behavior can be replaced
with provideIdleServiceWith.
Usage Notes
injectAsync(import(...), {prefetch: onIdle})
// or with custom idle options:
injectAsync(import(...), {prefetch: () => onIdle({timeout: 100})})
Jump to details