Limits of OnPush change detection when mutating @Input objects in Angular
0 reputation · 25 Apr 2021, 22:59 UTC
Goal: Ensure that a component using the OnPush change detection strategy reflects updates made to an @Input object without replacing the object's reference.
Constraint: OnPush only marks a component for check when the @Input reference changes or an internal event occurs; mutating properties or array elements in place does not trigger a view update, leaving the UI stale. The documentation notes this behavior but does not prescribe a universal solution, leaving developers to decide between immutable patterns, manual change detection triggers, or other work‑arounds.
What is the recommended approach to mutate nested @Input properties while retaining OnPush performance? Is there a supported Angular API to manually signal a change detection run for a specific OnPush component without bypassing its semantics? Does Angular provide a built‑in mechanism to deep‑watch @Input objects under OnPush?