MCPcopy Create free account
hub / github.com/angular/angular / executeOnDestroys

Function executeOnDestroys

packages/core/src/render3/node_manipulation.ts:439–473  ·  view source on GitHub ↗

Calls onDestroy hooks for this view

(tView: TView, lView: LView)

Source from the content-addressed store, hash-verified

437
438/** Calls onDestroy hooks for this view */
439function executeOnDestroys(tView: TView, lView: LView): void {
440 ngDevMode && assertNotReactive(executeOnDestroys.name);
441 let destroyHooks: DestroyHookData | null;
442
443 if (tView != null && (destroyHooks = tView.destroyHooks) != null) {
444 for (let i = 0; i < destroyHooks.length; i += 2) {
445 const context = lView[destroyHooks[i] as number];
446
447 // Only call the destroy hook if the context has been requested.
448 if (!(context instanceof NodeInjectorFactory)) {
449 const toCall = destroyHooks[i + 1] as HookFn | HookData;
450
451 if (Array.isArray(toCall)) {
452 for (let j = 0; j < toCall.length; j += 2) {
453 const callContext = context[toCall[j] as number];
454 const hook = toCall[j + 1] as HookFn;
455 profiler(ProfilerEvent.LifecycleHookStart, callContext, hook);
456 try {
457 hook.call(callContext);
458 } finally {
459 profiler(ProfilerEvent.LifecycleHookEnd, callContext, hook);
460 }
461 }
462 } else {
463 profiler(ProfilerEvent.LifecycleHookStart, context, toCall);
464 try {
465 toCall.call(context);
466 } finally {
467 profiler(ProfilerEvent.LifecycleHookEnd, context, toCall);
468 }
469 }
470 }
471 }
472 }
473}
474
475/**
476 * Returns a native element if a node can be inserted into the given parent.

Callers 1

cleanUpViewFunction · 0.85

Calls 3

assertNotReactiveFunction · 0.90
profilerFunction · 0.90
isArrayMethod · 0.80

Tested by

no test coverage detected