Skip to content

viatcheslav-zadorozhniy/ng-change-detection

Repository files navigation

Angular change detection in-depth

Table of contents

Description

What is it?

Change detection is the process through which Angular checks to see whether your application state has changed, and if any DOM needs to be updated.

How does it work?

NgZone (Angular execution context) is used to detect changes automatically. It is done using zone.js which patches standard web APIs.

How does it trigger?

It can be triggered manually (using ChangeDetectorRef) or automatically through an asynchronous event (more details).

Optimization

At a high level, Angular walks your components from top to bottom, looking for changes.

Change detection is highly optimized and performant, but it can still cause slowdowns if the application performs it too frequently.

Optimization tips:

Demo

Details

Installation

yarn install --frozen-lockfile