Misconceptions of Angular Change Detection
When an Angular application's performance decreases, I go through a simple and easy checklist of my own. Checking loose subscriptions, trackBy functions of in-template iterations, and change detection among others. Especially the latter had been mentioned in all the articles, webinars, and conferences, but since they usually don't dive deep, some details are often misunderstood.
Here are two things I missed from the documentation.
❌ Default change detection makes a deep check on Inputs
Practically it is not far from the truth, but it is a little smarter than that. An article by the Angular University states
by default, Angular does not do deep object comparison to detect changes, it only takes into account properties used by the template.
❌ OnPush change detection triggers only on input reference change
As per Victor Savkin, one of the lead developers of Angular
when using OnPush detectors, then the framework will check an OnPush component when any of its input properties changes, when it fires an event, or when an Observable fires an event.