Support registering namespaced view directories; add lib() universal path
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-06-24 00:14:04 -05:00
parent a69c81ed35
commit 7506d6567d
9 changed files with 201 additions and 17 deletions

View File

@@ -1,7 +1,8 @@
import {Instantiable} from './types'
import {DependencyKey, Instantiable} from './types'
import NamedFactory from './factory/NamedFactory'
import {AbstractFactory} from './factory/AbstractFactory'
import {Factory} from './factory/Factory'
import {ClosureFactory} from './factory/ClosureFactory'
export class ContainerBlueprint {
private static instance?: ContainerBlueprint
@@ -36,6 +37,16 @@ export class ContainerBlueprint {
return this
}
/**
* Register a producer function as a ClosureFactory with this container.
* @param key
* @param producer
*/
registerProducer(key: DependencyKey, producer: () => any): this {
this.factories.push(() => new ClosureFactory(key, producer))
return this
}
resolve(): AbstractFactory<any>[] {
return this.factories.map(x => x())
}