After uncovering the treasure that is forRoot() while delving deeper into Angular dependency injection (DI), I find myself pondering on the best practices for its usage.
I came across this method when trying to enable a lazy loaded module to access a service from the root context, allowing data to be shared between two modules, both of which could potentially be lazy loaded. This led me to question whether forRoot() could be used for all dependencies in a shared module, reducing the need for multiple import statements throughout an application. What are the potential drawbacks? Are there specific use cases where forRoot() works well, and others where it might not be appropriate? Is forRoot() primarily meant to address DI context issues when dealing with lazy loaded modules?