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

Function ɵɵdeferPrefetchOnViewport

packages/core/src/defer/instructions.ts:809–849  ·  view source on GitHub ↗
(
  triggerIndex: number,
  walkUpTimes?: number | null,
  options?: IntersectionObserverInit,
)

Source from the content-addressed store, hash-verified

807 * @codeGenApi
808 */
809export function ɵɵdeferPrefetchOnViewport(
810 triggerIndex: number,
811 walkUpTimes?: number | null,
812 options?: IntersectionObserverInit,
813) {
814 const lView = getLView();
815 const tNode = getCurrentTNode()!;
816
817 if (ngDevMode) {
818 const args: string[] = [];
819 if (walkUpTimes !== undefined && walkUpTimes !== -1) {
820 args.push('<target>');
821 }
822 if (options) {
823 args.push(JSON.stringify(options));
824 }
825 trackTriggerForDebugging(
826 lView[TVIEW],
827 tNode,
828 `prefetch on viewport${args.length === 0 ? '' : `(${args.join(', ')})`}`,
829 );
830 }
831
832 if (!shouldAttachTrigger(TriggerType.Prefetch, lView, tNode)) return;
833
834 const tView = lView[TVIEW];
835 const tDetails = getTDeferBlockDetails(tView, tNode);
836
837 if (tDetails.loadingState === DeferDependenciesLoadingState.NOT_STARTED) {
838 registerDomTrigger(
839 lView,
840 tNode,
841 triggerIndex,
842 walkUpTimes,
843 onViewportWrapper,
844 () => triggerPrefetching(tDetails, lView, tNode),
845 TriggerType.Prefetch,
846 options,
847 );
848 }
849}
850
851/**
852 * Creates runtime data structures for the `on viewport` hydrate trigger.

Callers

nothing calls this directly

Calls 9

getLViewFunction · 0.90
getCurrentTNodeFunction · 0.90
trackTriggerForDebuggingFunction · 0.90
shouldAttachTriggerFunction · 0.90
getTDeferBlockDetailsFunction · 0.90
registerDomTriggerFunction · 0.90
triggerPrefetchingFunction · 0.90
joinMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected