How to run long tasks in Angular environment injector

Loading

Reading Time: 5 minutes Introduction Angular 14 introduced ENVIRONMENT_INITIALIZER token that enables developers to run long tasks during the construction of Angular environment injector. For standalone component, I inject the new token in the providers array and pass the provider to bootstrapApplication() function. Moreover, I found a use case of hierarchical dependency (explained here) where inject() ensures this provider … Read more

DOM reading and writing with new lifecycle hooks in Angular

Loading

Reading Time: 4 minutes Introduction In Angular 16, Angular has added two new lifecycle hooks, afterNextRender and afterRender, for DOM reading and writing. According to the Angular documentation, afterNextRender is similar to AfterViewInit but it does not cause issues that AfterViewInit has in SSR. On the other hand, afterRender executes after every change detection to synchronize state with DOM. … Read more