MCPcopy Index your code
hub / github.com/angular/angular / ɵɵdeferPrefetchWhen

Function ɵɵdeferPrefetchWhen

packages/core/src/defer/instructions.ts:268–294  ·  view source on GitHub ↗
(rawValue: unknown)

Source from the content-addressed store, hash-verified

266 * @codeGenApi
267 */
268export function ɵɵdeferPrefetchWhen(rawValue: unknown) {
269 const lView = getLView();
270 const tNode = getSelectedTNode();
271
272 if (ngDevMode) {
273 trackTriggerForDebugging(lView[TVIEW], tNode, 'prefetch when <expression>');
274 }
275
276 if (!shouldAttachTrigger(TriggerType.Prefetch, lView, tNode)) return;
277
278 const bindingIndex = nextBindingIndex();
279
280 if (bindingUpdated(lView, bindingIndex, rawValue)) {
281 const prevConsumer = setActiveConsumer(null);
282 try {
283 const value = Boolean(rawValue); // handle truthy or falsy values
284 const tView = lView[TVIEW];
285 const tDetails = getTDeferBlockDetails(tView, tNode);
286 if (value === true && tDetails.loadingState === DeferDependenciesLoadingState.NOT_STARTED) {
287 // If loading has not been started yet, trigger it now.
288 triggerPrefetching(tDetails, lView, tNode);
289 }
290 } finally {
291 setActiveConsumer(prevConsumer);
292 }
293 }
294}
295
296/**
297 * Hydrates the deferred content when a value becomes truthy.

Callers

nothing calls this directly

Calls 9

getLViewFunction · 0.90
getSelectedTNodeFunction · 0.90
trackTriggerForDebuggingFunction · 0.90
shouldAttachTriggerFunction · 0.90
nextBindingIndexFunction · 0.90
bindingUpdatedFunction · 0.90
setActiveConsumerFunction · 0.90
getTDeferBlockDetailsFunction · 0.90
triggerPrefetchingFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…