Container
Defined in: src/decorators/util/container.ts:7
Simple Dependency Injection Container
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Container():
Container
Returns
Section titled “Returns”Container
Methods
Section titled “Methods”
staticget<T>(target):T
Defined in: src/decorators/util/container.ts:27
Get a service instance from the container.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”target
Section titled “target”(…args) => T
The constructor function of the service.
Returns
Section titled “Returns”T
The instance of the service, or undefined if not found.
statichas(target):boolean
Defined in: src/decorators/util/container.ts:36
Check if a service is registered in the container.
Parameters
Section titled “Parameters”target
Section titled “target”any
The constructor function of the service.
Returns
Section titled “Returns”boolean
True if the service is registered, false otherwise.
register()
Section titled “register()”
staticregister<T>(target,instance):void
Defined in: src/decorators/util/container.ts:18
Register a service instance in the container.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”target
Section titled “target”(…args) => T
The constructor function of the service.
instance
Section titled “instance”T
The instance of the service to register.
Returns
Section titled “Returns”void
resolve()
Section titled “resolve()”
staticresolve<T>(target):T
Defined in: src/decorators/util/container.ts:45
Resolve a service instance from the container.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”target
Section titled “target”(…args) => T
The constructor function of the service.
Returns
Section titled “Returns”T
The instance of the service, or undefined if not found.
teardown()
Section titled “teardown()”
staticteardown():Promise<void>
Defined in: src/decorators/util/container.ts:113
Teardown the container, destroying all singletons and clearing the cache.
Returns
Section titled “Returns”Promise<void>