MCPcopy Index your code
hub / github.com/angular/angular / scheduleDelayedPrefetching

Function scheduleDelayedPrefetching

packages/core/src/defer/triggering.ts:106–126  ·  view source on GitHub ↗
(
  scheduleFn: (callback: VoidFunction, injector: Injector) => VoidFunction,
)

Source from the content-addressed store, hash-verified

104 * @param scheduleFn A function that does the scheduling.
105 */
106export function scheduleDelayedPrefetching(
107 scheduleFn: (callback: VoidFunction, injector: Injector) => VoidFunction,
108) {
109 if (typeof ngServerMode !== 'undefined' && ngServerMode) return;
110
111 const lView = getLView();
112 const injector = lView[INJECTOR];
113
114 // Only trigger the scheduled trigger on the browser
115 // since we don't want to delay the server response.
116 const tNode = getCurrentTNode()!;
117 const tView = lView[TVIEW];
118 const tDetails = getTDeferBlockDetails(tView, tNode);
119
120 if (tDetails.loadingState === DeferDependenciesLoadingState.NOT_STARTED) {
121 const lDetails = getLDeferBlockDetails(lView, tNode);
122 const prefetch = () => triggerPrefetching(tDetails, lView, tNode);
123 const cleanupFn = scheduleFn(prefetch, injector);
124 storeTriggerCleanupFn(TriggerType.Prefetch, lDetails, cleanupFn);
125 }
126}
127
128/**
129 * Schedules hydration triggering of a defer block for `on idle` and `on timer` conditions.

Callers 2

ɵɵdeferPrefetchOnIdleFunction · 0.90
ɵɵdeferPrefetchOnTimerFunction · 0.90

Calls 6

getLViewFunction · 0.90
getCurrentTNodeFunction · 0.90
getTDeferBlockDetailsFunction · 0.90
getLDeferBlockDetailsFunction · 0.90
storeTriggerCleanupFnFunction · 0.90
scheduleFnFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…