0

I work on an Angular application which use several third party libraries (leaflet/wijmo/d3/..).

For performances, I already use cdRef.OnPush almost everywhere.

And to prevent too many Zone runs, I use zone.runOutsideAngular() inside some specific components but I've seen some weird behaviors and would like to understand more when and from where (in MY code) Zone is triggered.

Do you know a way to log this?

[angular@5.2.3 & zone.js@0.8.19]

bertrandg
  • 3,147
  • 2
  • 27
  • 35
  • Not sure about your question, but maybe this is a good read on the topic: https://blog.thoughtram.io/angular/2016/02/01/zones-in-angular-2.html – ForestG Mar 22 '18 at 13:03
  • thanks I've already read it but that's not what I want. I would like to log when it's triggered and from where to debug an app. – bertrandg Mar 22 '18 at 16:29
  • what do you mean Zone is triggered? – jiali passion Mar 23 '18 at 02:48
  • @jialipassion I mean when and what async code has been detected by Zone, which tell to Angular to run change detection. – bertrandg Mar 23 '18 at 09:25

1 Answers1

1

you can use NgZone.onStable

@Component {
  ...
} 
export class AppComponent {
  constructor (private ngZone: NgZone) {
    this.ngZone.onStable.subscribe(() => {console.log('zone stableed')});
  }
}
jiali passion
  • 1,691
  • 1
  • 14
  • 19
  • Thanks, using `onStable` & `onUnstable` observables, I got what I wanted but find where it come from in my code is not an easy task! :) – bertrandg Mar 26 '18 at 14:32