Change Detection runs all time even if map is not present
See original GitHub issueThe issue is than if you have <agm-map>
in component with *ngIf
on it, the change detection runs every second after it is shown.
Steps to reproduce and a minimal demo of the problem
I created repo for reproduction.
What steps should we try in your demo to see the problem?
- Clone the repo.
- Put your API_KEY to app.module.ts.
- Run with
ng serve
- Open the console window.
- Click on Show/Hide button - Map hides and change detection runs only couple of times and then stops
- Click on Show/Hide button again - Map is shown and in console the change detection logs keep running / there is also so much change detection running if you hover over
angular2 & angular-google-maps version
"@agm/core": "1.0.0-beta.0"
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:9
Top Results From Across the Web
Change Detection runs all time even if map is not present #1019
The issue is than if you have <agm-map> in component with *ngIf on it, the change detection runs every second after it is...
Read more >Angular Change Detection - How Does It Really Work?
Change detection works by detecting common browser events like mouse clicks, HTTP requests, and other types of events, and deciding if the view ......
Read more >The Last Guide For Angular Change Detection You'll Ever Need
It will run change detection on marked components even though they are using the OnPush strategy.
Read more >typescript - Run Angular change detection only once and stop ...
So i have many *ngIf in a single html template but i need to check *ngIf condition only once when the template is...
Read more >Angular Change Detection | InfiniSwiss Blog
Change Detection can be defined as the process of identifying differences in the state of an object by observing it at different times....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@SebastianM
I believe I tracked down where this issue is coming from. In the constructor for FitBoundsService, there’s an observable pipeline definition which basically samples the includeInBounds$ observable based on a variable timer, and then maps that onto a generation of the bounds.
The first problem is the internal timer is triggering angular change tracking every time it fires (by default, 5 times per second) regardless of whether the observable it’s sampling has a new value.
The second is that the FitBoundsService is not disposed on map-hide, but a new instance is created the next time the map is shown. This leak leads to very bad performance if change checking is remotely expensive.
I’m fairly new the RxJS and the Angular change-tracking system, so I’m not at all sure what the appropriate fix is here. Hopefully finding the problem will make this easy for someone more skilled than me.
Any update on this issue?