Class: ContainerBuilder

October 4, 2024 · View on GitHub

DIOD v3.0.0Docs


Class: ContainerBuilder

Used to build an Container from service registrations.

Constructors

new ContainerBuilder()

new ContainerBuilder(): ContainerBuilder

Returns

ContainerBuilder

Methods

build()

build(options): Container

Builds an immutable Container.

Parameters

options: BuildOptions = {}

Build options.

Returns

Container


isRegistered()

isRegistered<T>(identifier): boolean

Checks whether a service is registered or not.

Type Parameters

T

The type of the service.

Parameters

identifier: Identifier<T>

The class that identifies this service to be checked.

Returns

boolean


register()

register<T>(identifier): Registration<T>

Registers a service.

Type Parameters

T

The type of the service.

Parameters

identifier: Identifier<T>

The class that identifies this service. This class identifier must be used to get the service from the container or when defining it as a dependency.

Returns

Registration<T>


registerAndUse()

registerAndUse<T>(newable): ConfigurableRegistration & WithScopeChange & WithDependencies

Alias for .register(newable).use(newable).

Type Parameters

T

The type of the service.

Parameters

newable: Newable<T>

The concrete class implementation to be registered as itself.

Returns

ConfigurableRegistration & WithScopeChange & WithDependencies


unregister()

unregister<T>(identifier): void

Unregister previously registered service.

Type Parameters

T

The type of the service.

Parameters

identifier: Identifier<T>

The class that identifies this service to be unregistered.

Returns

void