MCPcopy
hub / github.com/angular/angular / constructor

Method constructor

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

Source from the content-addressed store, hash-verified

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