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

Method constructor

packages/core/src/testability/testability.ts:106–128  ·  view source on GitHub ↗
(
    private _ngZone: NgZone,
    private registry: TestabilityRegistry,
    @Inject(TESTABILITY_GETTER) testabilityGetter: GetTestability,
  )

Source from the content-addressed store, hash-verified

104 private readonly pendingTasksInternal = inject(PendingTasksInternal);
105 private readonly _usePendingTasks = inject(USE_PENDING_TASKS);
106 constructor(
107 private _ngZone: NgZone,
108 private registry: TestabilityRegistry,
109 @Inject(TESTABILITY_GETTER) testabilityGetter: GetTestability,
110 ) {
111 // Attempt to retrieve a `DestroyRef` optionally.
112 // For backwards compatibility reasons, this cannot be required.
113 if (isInInjectionContext()) {
114 this._destroyRef = inject(DestroyRef, {optional: true}) ?? undefined;
115 }
116
117 // If there was no Testability logic registered in the global scope
118 // before, register the current testability getter as a global one.
119 if (!_testabilityGetter) {
120 setTestabilityGetter(testabilityGetter);
121 testabilityGetter.addToWindow(registry);
122 }
123 this._watchAngularEvents();
124 _ngZone.run(() => {
125 this._taskTrackingZone =
126 typeof Zone == 'undefined' ? null : Zone.current.get('TaskTrackingZone');
127 });
128 }
129
130 private _watchAngularEvents(): void {
131 const onUnstableSubscription = this._ngZone.onUnstable.subscribe({

Callers

nothing calls this directly

Calls 8

_watchAngularEventsMethod · 0.95
InjectInterface · 0.90
isInInjectionContextFunction · 0.90
injectFunction · 0.90
setTestabilityGetterFunction · 0.85
addToWindowMethod · 0.65
runMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected