A demonstration of using modules and injectors for specific use cases
- How to load a runtime config?
- Who’s Injector is it anyway?
- Constraints of third party initialisation
- Using Angular core APP_INITIALIZER token we can load data from an external file or api before the app spins up.
- By using a service in its factory, we can store the result in the service for easy injection later and to pass it to a token to use immediately within the module schema.
- The token containing library-specific config can be passed into the lib via its forRoot method.
See branch feature/whos-provider-is-it-anyway
Proof that forRoot Providers mingle and override Providers from @NgModule schema in the same module file
See file libs/shared/ui-my-configurable-component/src/lib/shared-ui-my-configurable-component.module.ts
Proof that imported modules can access the same singletons provided by other imported modules into the same parent module
See file libs/injectors-demo/feature-providers-test/src/lib/injectors-demo-feature-providers-test.module.ts
See branch feature/third-party-module-config-for-dev-and-prod
See file libs/injectors-demo/feature-shell/src/lib/injectors-demo-feature-shell.module.ts
See file apps/injectors-demo/src/app/app.module.ts