(zone: NgZonePrivate)
| 352 | } |
| 353 | |
| 354 | function 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 | |
| 387 | function delayChangeDetectionForEvents(zone: NgZonePrivate) { |
| 388 | /** |
no test coverage detected
searching dependent graphs…