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

Function checkStable

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

Source from the content-addressed store, hash-verified

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

Callers 3

scheduleCheckStableFunction · 0.85
onLeaveFunction · 0.85

Calls 2

emitMethod · 0.65
runOutsideAngularMethod · 0.45

Tested by

no test coverage detected