(rawValue: unknown)
| 271 | * @codeGenApi |
| 272 | */ |
| 273 | export 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. |
nothing calls this directly
no test coverage detected