angular2-esri-playground
angular2-esri-playground copied to clipboard
Change detection runs continuously
@tomwayson @jwasilgeo I discovered this issue in my own project and narrowed it down to the map loading. You can verify this by implementing NgAfterViewChecked in one of your components.
I found the solution from this post: http://stackoverflow.com/questions/38995262/how-to-disable-angular2-change-detection-for-3rd-party-libraries
Basically you want to wrap the map and mapView loads with ngZone.runOutsideAngular(()=>{})
esri-map-view.component.ts: ngOnInit() { this.zone.runOutsideAngular(() => { this.view = new MapView({ ....... }.bind(this)); }); }
map.service.ts: constructor(private zone: NgZone) { this.zone.runOutsideAngular(() => { this.map = new Map({ ........ }); }); }
Wrapping the the MapView seems to fix the continuous change detection, but wrapping the Map reduced the number of rounds of change detection even further.
I haven't observed any side-effects in my own project from doing this. Hope this helps somebody. I thought this issue was going to be my demise.