Containers - add ability to purge/release factories; override factories in scoped
This commit is contained in:
@@ -47,6 +47,25 @@ export class Container {
|
||||
this.registerSingleton('injector', this)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge all factories and instances of the given key from this container.
|
||||
* @param key
|
||||
*/
|
||||
purge(key: DependencyKey): this {
|
||||
this.factories = this.factories.filter(x => !x.match(key))
|
||||
this.release(key)
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all stored instances of the given key from this container.
|
||||
* @param key
|
||||
*/
|
||||
release(key: DependencyKey): this {
|
||||
this.instances = this.instances.filter(x => x.key !== key)
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a basic instantiable class as a standard Factory with this container.
|
||||
* @param {Instantiable} dependency
|
||||
|
||||
Reference in New Issue
Block a user