App Factory
Loading Subversify modules is easy using the built-in Inversify loadAsync
method, but Subversify also provides a simple AppFactory to help enforce a few
small best practices:
- The root container should load only one Subversify module root for consistent binding behaviour
- The root container should have a
defaultScopeofSingleton - The root container should not require manual configuration
The AppFactory exposes a create factory method that only accepts a single
module, and resolves to a Promise with the configured root container:
Options
To support progressively migrating to modules in existing applications, the root
container can be provided in the optional options argument:
Caution
For application root containers with a defaultScope of Transient,
this "should" be fine as all modules are Singleton by default, although this
has not been tested extensively.