Open dgeb opened 7 years ago
I just tweaked the description of this issue, which originally mentioned a simplification for registration options. However, I realized that this was an oversimplification since we still need to register options (like singleton: false
) by type
.
In a
Registry
, both factories and instances can be registered viaregister
, unregistered viaunregister
, and accessed viaregistration
.@krisselden and I discussed the benefits of separating the interfaces to register factories and instances. This change will provide stronger typing for storing and accessing factories and instances.
This would entail the following changes:
Registry#register
to accept a more strongly typedFactoryDefinition<any>
Registry
:registerInstance(specifier: string, instance: any): void
unregisterInstance(specifier: string): void
registeredInstance(specifier: string): any
Container#lookup
, check the registry'sregisteredInstance
as a first step and return an instance if found.