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

Function shouldAttachRegularTrigger

packages/core/src/defer/triggering.ts:615–638  ·  view source on GitHub ↗

* Defines whether a regular trigger logic (e.g. "on viewport") should be attached * to a defer block. This function defines a condition, which mutually excludes * `deferOn*` and `deferHydrateOn*` triggers, to make sure only one of the trigger * types is active for a block with the current state.

(lView: LView, tNode: TNode)

Source from the content-addressed store, hash-verified

613 * types is active for a block with the current state.
614 */
615function shouldAttachRegularTrigger(lView: LView, tNode: TNode): boolean {
616 const injector = lView[INJECTOR];
617
618 const tDetails = getTDeferBlockDetails(lView[TVIEW], tNode);
619 const incrementalHydrationEnabled = isIncrementalHydrationEnabled(injector);
620 const _hasHydrateTriggers = hasHydrateTriggers(tDetails.flags);
621
622 // On the server:
623 if (typeof ngServerMode !== 'undefined' && ngServerMode) {
624 // Regular triggers are activated on the server when:
625 // - Either Incremental Hydration is *not* enabled
626 // - Or Incremental Hydration is enabled, but a given block doesn't have "hydrate" triggers
627 return !incrementalHydrationEnabled || !_hasHydrateTriggers;
628 }
629
630 // On the client:
631 const lDetails = getLDeferBlockDetails(lView, tNode);
632 const wasServerSideRendered = lDetails[SSR_UNIQUE_ID] !== null;
633
634 if (_hasHydrateTriggers && wasServerSideRendered && incrementalHydrationEnabled) {
635 return false;
636 }
637 return true;
638}
639
640/**
641 * Retrives a Defer Block's list of hydration triggers

Callers 1

shouldAttachTriggerFunction · 0.85

Calls 4

getTDeferBlockDetailsFunction · 0.90
getLDeferBlockDetailsFunction · 0.90
hasHydrateTriggersFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…