0

I have researched a lot and found that one of the performance techniques is to set ChangeDetectionStrategy to OnPush in Angular to reduce modification numbers in Angular App, but can be some cases when it's not recommended to use it?

I will start using it in Ionic Angular Application with a declarative/reactive RxJS pattern.

It will be so nice to suggest to me some keywords to increase performance to the max.

solimanware
  • 2,952
  • 4
  • 20
  • 40
  • Does this answer your question? [Should use ChangeDetectionStrategy.OnPush for eveything?](https://stackoverflow.com/questions/53426412/should-use-changedetectionstrategy-onpush-for-eveything) – Jacopo Sciampi Dec 03 '21 at 13:57

1 Answers1

1

i don't think there is any real reason to use the DefaultStrategy.

However if you go with OnPush (which i highly encourage you to) you have to ensure you do not mutate your @Inputs but you keep them immutable and replace the whole instance that it points to.

Sometimes you may find yourself mutating by accident. In those cases Angulars ChangeDetection will not trigger by itself when using OnPush and you may have a hard time to figure out where it fails.

The DefaultStrategy is much less error prone in those scenarios and maybe, if your components are small and performance impact is low you do not want to take the rocky road and just keep the DefaultStrategy.

Malte
  • 114
  • 9