MCPcopy
hub / github.com/angular/angular / checkStable

Function checkStable

packages/core/src/zone/ng_zone.ts:354–385  ·  view source on GitHub ↗
(zone: NgZonePrivate)

Source from the content-addressed store, hash-verified

352}
353
354function checkStable(zone: NgZonePrivate) {
355 // TODO: @JiaLiPassion, should check zone.isCheckStableRunning to prevent
356 // re-entry. The case is:
357 //
358 // @Component({...})
359 // export class AppComponent {
360 // constructor(private ngZone: NgZone) {
361 // this.ngZone.onStable.subscribe(() => {
362 // this.ngZone.run(() => console.log('stable'););
363 // });
364 // }
365 //
366 // The onStable subscriber run another function inside ngZone
367 // which causes `checkStable()` re-entry.
368 // But this fix causes some issues in g3, so this fix will be
369 // launched in another PR.
370 if (zone._nesting == 0 && !zone.hasPendingMicrotasks && !zone.isStable) {
371 try {
372 zone._nesting++;
373 zone.onMicrotaskEmpty.emit(null);
374 } finally {
375 zone._nesting--;
376 if (!zone.hasPendingMicrotasks) {
377 try {
378 zone.runOutsideAngular(() => zone.onStable.emit(null));
379 } finally {
380 zone.isStable = true;
381 }
382 }
383 }
384 }
385}
386
387function delayChangeDetectionForEvents(zone: NgZonePrivate) {
388 /**

Callers 3

scheduleCheckStableFunction · 0.85
onLeaveFunction · 0.85

Calls 2

emitMethod · 0.65
runOutsideAngularMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…