(rawValue: unknown)
| 266 | * @codeGenApi |
| 267 | */ |
| 268 | export 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. |
nothing calls this directly
no test coverage detected
searching dependent graphs…