Initializing asynchronous dependencies
Referring to asynchronous values is toxic because every value computed from the referred value must be asynchronous as well. A couple of techniques to get around this are available, but they both come at the cost of delaying application bootstrapping until the value has been resolved. These techniques are demonstrated in this section.
Providing an asynchronous dependency with a static platform provider
To convert an asynchronous dependency resolver to a static dependency, we can delay bootstrapping our application to provide the static provider at the platform level, making it available as a static dependency in our application.
For example, say we have a JSON file containing an object with Boolean values. We create it in the src/app/assets/features.json
file of our application project. This file contains our feature flags, which are loaded at runtime. The settings in this file can be changed after compiling our application.
In the...