onIdle
A PrefetchTrigger helper function to provide the logic of triggering dependency loading when the browser becomes idle.
API
function onIdle(
options?: { timeout?: number | undefined } | undefined,
): Promise<void>;
@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})})
Super-powered by Google ©2010–2025.
Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0.
https://angular.dev/api/core/onIdle