MCPcopy Create free account
hub / github.com/angular/angular / ɵɵdeferPrefetchWhen

Function ɵɵdeferPrefetchWhen

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

Source from the content-addressed store, hash-verified

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