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

Function executeOnDestroys

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

Calls onDestroy hooks for this view

(tView: TView, lView: LView)

Source from the content-addressed store, hash-verified

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