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

Method constructor

packages/core/src/zone/ng_zone.ts:136–185  ·  view source on GitHub ↗
(options: {
    enableLongStackTrace?: boolean;
    shouldCoalesceEventChangeDetection?: boolean;
    shouldCoalesceRunChangeDetection?: boolean;
  })

Source from the content-addressed store, hash-verified

134 readonly onError: EventEmitter<any> = new EventEmitter(false);
135
136 constructor(options: {
137 enableLongStackTrace?: boolean;
138 shouldCoalesceEventChangeDetection?: boolean;
139 shouldCoalesceRunChangeDetection?: boolean;
140 }) {
141 const {
142 enableLongStackTrace = false,
143 shouldCoalesceEventChangeDetection = false,
144 shouldCoalesceRunChangeDetection = false,
145 scheduleInRootZone = SCHEDULE_IN_ROOT_ZONE_DEFAULT,
146 } = options as InternalNgZoneOptions;
147
148 if (typeof Zone == 'undefined') {
149 throw new RuntimeError(
150 RuntimeErrorCode.MISSING_ZONEJS,
151 ngDevMode && `In this configuration Angular requires Zone.js`,
152 );
153 }
154
155 Zone.assertZonePatched();
156 const self = this as any as NgZonePrivate;
157 self._nesting = 0;
158
159 self._outer = self._inner = Zone.current;
160
161 // AsyncStackTaggingZoneSpec provides `linked stack traces` to show
162 // where the async operation is scheduled. For more details, refer
163 // to this article, https://developer.chrome.com/blog/devtools-better-angular-debugging/
164 // And we only import this AsyncStackTaggingZoneSpec in development mode,
165 // in the production mode, the AsyncStackTaggingZoneSpec will be tree shaken away.
166 if (ngDevMode) {
167 self._inner = self._inner.fork(new AsyncStackTaggingZoneSpec('Angular'));
168 }
169
170 if ((Zone as any)['TaskTrackingZoneSpec']) {
171 self._inner = self._inner.fork(new ((Zone as any)['TaskTrackingZoneSpec'] as any)());
172 }
173
174 if (enableLongStackTrace && (Zone as any)['longStackTraceZoneSpec']) {
175 self._inner = self._inner.fork((Zone as any)['longStackTraceZoneSpec']);
176 }
177 // if shouldCoalesceRunChangeDetection is true, all tasks including event tasks will be
178 // coalesced, so shouldCoalesceEventChangeDetection option is not necessary and can be skipped.
179 self.shouldCoalesceEventChangeDetection =
180 !shouldCoalesceRunChangeDetection && shouldCoalesceEventChangeDetection;
181 self.shouldCoalesceRunChangeDetection = shouldCoalesceRunChangeDetection;
182 self.callbackScheduled = false;
183 self.scheduleInRootZone = scheduleInRootZone;
184 forkInnerZoneWithAngularBehavior(self);
185 }
186
187 /**
188 This method checks whether the method call happens within an Angular Zone instance.

Callers

nothing calls this directly

Implementers 1

NoopNgZonepackages/core/src/zone/ng_zone.ts

Calls 3

assertZonePatchedMethod · 0.65
forkMethod · 0.65

Tested by

no test coverage detected