DEV Community

Angular Components Lifecycle - Basics

Pantelis Papasavvas on January 29, 2024

As developers working with Angular, we rely on its lifecycle hooks to manage how our components are created, updated, and destroyed. Understanding ...
Collapse
 
jwhenry3 profile image
Justin Henry

I would recommend as a next article to dive into change detection, as it elaborates on the concept of ngDoCheck. Converting default components to use OnPush change detection should improve performance for many components and utilizing ChangeDetectorRef to tell the component to trigger change detection explicitly can give the developer more power in how to fine tune their components.

Another aspect of change detection to dive into would be the async pipe, which will update the template on observable emission without needing to trigger the change detection manually, which makes it useful in OnPush in reducing the number of explicit triggers of the ChangeDetectorRef.

Of course much of this will shift once Signals is officially released and fully supported. That will be an entirely separate book.

Collapse
 
pantpapasavvas profile image
Pantelis Papasavvas

Hello Justin.
I'll manage to create an article to dive deeper into that concept.

Thanks for your feedback.

Collapse
 
pbouillon profile image
Pierre Bouillon

It would have been great to mention afterRender and afterNextRender as well

Collapse
 
pantpapasavvas profile image
Pantelis Papasavvas

Hello Pierre.
In my opinion, those hooks are not commonly used so I left them out of this article.
I'll create a new one for those.

Thanks for your feedback.