But to be functional this static method will need at least the sources option. See the environment module config documentation to know more about all the options.
You can avoid the use of the forRoot() static method injecting all the required tokens. This option can help if any token must be calculated, for example by using a factory function. The provided instances will override the ones provided by forRoot().
If a feature module load in a lazy way needs to load s custom set of sources it can be done using the forChild() ststic method or injecting the sources and the loader tokens. See the sources documentation to know more details.
Once injected the module should execute the load() method of EnvironmentModule to load all the sources into the common environment state.
Angular Environment Module
EnvironmentModule
The enfironment module manages the injection of services required by the environment module.
To create an instance of all default services simply call the module
.forRoot()
static method.But to be functional this static method will need at least the
sources
option. See the environment module config documentation to know more about all the options.Use cases
Below are examples of the expected behavior and some implementation examples.
Table of Contents
Using Injection Tokens
You can avoid the use of the
forRoot()
static method injecting all the required tokens. This option can help if any token must be calculated, for example by using a factory function. The provided instances will override the ones provided byforRoot()
.Lazy Feature Module with the same loader and sources
If the environment singleton services are required in a lazy loaded module simply import
EnvironmentModule
.Lazy Feature Module with custom loader and sources
If a feature module load in a lazy way needs to load s custom set of sources it can be done using the
forChild()
ststic method or injecting the sources and the loader tokens. See the sources documentation to know more details.Once injected the module should execute the
load()
method of EnvironmentModule to load all the sources into the common environment state.