Stepan Suvorov
Stepan Suvorov

Reputation: 26236

Why markForCheck() works only for one branch?

It's clear that we need to use markForCheck() mostly with OnPush strategy to mark component to do the CD check, but

I'm trying to figure out why to check only one branch:

enter image description here

Why could run CD for whole app or only specific component, no?

Upvotes: 1

Views: 428

Answers (1)

Stepan Suvorov
Stepan Suvorov

Reputation: 26236

thanks to comments from @yurzui @Toxicable @Maximus I came to understanding that:

Why not on each component?

That was the idea about onPush Strategy optimization: to run it only if it's necessary.

Why the whole branch, but not only one component?

Because it's how CD is made - it always goes from root component down. So if you want to run CD on specific component you need to make all the path from root to this specific component

Upvotes: 2

Related Questions