• 개요
@angular/core

onIdle

함수
안정화v22.0부터

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
@returnsPromise<void>

설명

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.

사용 시 참고사항

injectAsync(import(...), {prefetch: onIdle})

// or with custom idle options:
injectAsync(import(...), {prefetch: () => onIdle({timeout: 100})})
상세 내용으로 이동