The OnPush change detections strategy triggers change detection only
1) when @Input data is updated and that too, with conditions
a) If The update is a reference type and not a mutation (pushed in and not slipped in)
b) in case of observables as @Input() data, if it uses async pipe
2) User interactions/events are set in motion
3) when it is manually triggered
I can use OnPush when my component's data is mostly coming in from the outside and I am not changing the data via mutation (ie., I am only using immutable patterns to make changes). It is also an excellent choice when I am using async pipe in my component and all its data comes from observables
Top comments (0)