Change detection: events, zones, OnPush, signals
Why did that render?
Angular keeps the DOM in sync with your model through change detection: after any asynchronous event (click, HTTP response, timer), Angular walks the component tree and checks bindings against the model. Default strategy checks everything; OnPush restricts checks to subtrees whose inputs changed by reference or whose events originated within them; signals make the dependency graph explicit for fine-grained updates.
Three strategies, one question
- Default — safe, simple, pays at large trees.
- OnPush — opt in per component; use immutable inputs and
asyncpipes. - Signals —
signal()holds state,computed()tracks dependencies, the template reads minimal updates.
Takeaways
- Events start a change detection pass; the strategy decides how wide.
- OnPush needs immutable inputs to shine.
- Signals are the modern answer to "why did that unrelated component re-render?"
Enjoying This Lesson?
Your support helps create more comprehensive courses and lessons like this one. Help me build better learning experiences for everyone.
Support Awashyak