ReadonlyisWhether this container is disposed.
ReadonlyoptionsThe options used to create this container.
ReadonlyparentThe parent container, or undefined if this is the root container.
Adds a hook to observe the lifecycle of container-managed values.
Does nothing if the hook has already been added.
Clears and returns all distinct values that were cached by this container. Values from ValueProvider registrations are not included, as they are never cached.
Note that only this container is affected. Parent or child containers, if any, remain unchanged.
Creates a new child container that inherits this container's options.
You can pass specific options to override the inherited ones.
Optionaloptions: Partial<ChildContainerOptions>Disposes this container and all its cached values.
Token values implementing a Disposable interface (e.g., objects with a dispose() function)
are automatically disposed during this process.
Note that children containers are disposed first, in creation order.
Returns all cached values associated with registrations of the token, in the order they were registered, or an empty array if none have been cached.
If the token has at least one registration in the current container, cached values are taken from those registrations. Otherwise, cached values may be retrieved from parent containers, if any.
Values are never cached for tokens with Transient or Resolution scope, or for ValueProvider registrations.
Returns the cached value from the most recent registration of the token,
or undefined if no value has been cached yet (the token has not been resolved yet).
If the token has at least one registration in this container, the cached value is taken from the most recent of those registrations. Otherwise, it may be retrieved from parent containers, if any.
Values are never cached for tokens with Transient or Resolution scope, or for ValueProvider registrations.
Registers a ClassProvider, using the class itself as its token.
Tokens provided via the Injectable decorator applied to the class are also registered as aliases.
The scope is determined by the Scoped decorator - if present - or by the ContainerOptions.defaultScope value.
Registers a token type with a default Provider and optional default registration options.
Registers a ClassProvider with a token.
The default registration scope is determined by the Scoped decorator applied to the provided class - if present - or by the ContainerOptions.defaultScope value, but it can be overridden by passing explicit registration options.
Optionaloptions: RegistrationOptionsRegisters a FactoryProvider with a token.
Optionaloptions: RegistrationOptionsRegisters an ExistingProvider with a token.
The token will alias the one set in useExisting.
Registers a ValueProvider with a token.
Values provided via useValue are never cached (scopes do not apply)
and are simply returned as-is.
Removes a previously added hook.
Does nothing if the hook has not been added yet.
Removes all registrations from this container's internal registry.
Returns an array of the distinct values that were cached by this container for the removed registrations. Values from ValueProvider registrations are not included, as they are not cached.
Note that only this container is affected. Parent or child containers, if any, remain unchanged.
Resolves the given class to the instance associated with it.
If the class is registered in this container or any of its parent containers, an instance is created using the most recent registration.
If the class is not registered, but it is decorated with AutoRegister, or ContainerOptions.autoRegister is true, the class is registered automatically. Otherwise, the resolution fails.
The scope for the automatic registration is determined by either the Scoped decorator on the class, or ContainerOptions.defaultScope.
If the class is not registered in this container or any of its parent containers and could not be auto-registered, an error is thrown.
The resolution behavior depends on the Provider used during registration:
If the class is registered with Container scope, the resolved instance is cached in the container's internal registry.
Optionalname: stringResolves the given token to the value associated with it.
If the token is registered in this container or any of its parent containers, its value is resolved using the most recent registration.
If the token is not registered in this container or any of its parent containers, an error is thrown.
The resolution behavior depends on the Provider used during registration:
If the token is registered with Container scope, the resolved value is cached in the container's internal registry.
Resolves the given class to all instances provided by the registrations associated with it.
If the class is not registered, but it is decorated with AutoRegister, or ContainerOptions.autoRegister is true, the class is registered automatically. Otherwise, the resolution fails.
The scope for the automatic registration is determined by either the Scoped decorator on the class, or ContainerOptions.defaultScope.
If the class is not registered in this container or any of its parent containers and could not be auto-registered, an error is thrown.
The resolution behavior depends on the Provider used during registration:
If the class is registered with Container scope, the resolved instances are cached in the container's internal registry.
A separate instance of the class is created for each provider.
Resolves the given token to all values provided by the registrations associated with it.
If the token is not registered in this container or any of its parent containers, an error is thrown.
The resolution behavior depends on the Provider used during registration:
If the token is registered with Container scope, the resolved values are cached in the container's internal registry.
Resolves the given class to the instance associated with it.
If the class is registered in this container or any of its parent containers, an instance is created using the most recent registration.
If the class is not registered, but it is decorated with AutoRegister, or ContainerOptions.autoRegister is true, the class is registered automatically. Otherwise, the resolution fails.
The scope for the automatic registration is determined by either the Scoped decorator on the class, or ContainerOptions.defaultScope.
If the class is not registered in this container or any of its parent containers
and could not be auto-registered, undefined is returned instead.
The resolution behavior depends on the Provider used during registration:
If the class is registered with Container scope, the resolved instance is cached in the container's internal registry.
Optionalname: stringTries to resolve the given token to the value associated with it.
If the token is registered in this container or any of its parent containers, its value is resolved using the most recent registration.
If the token is not registered in this container or any of its parent containers,
undefined is returned instead.
The resolution behavior depends on the Provider used during registration:
If the token is registered with Container scope, the resolved value is cached in the container's internal registry.
Resolves the given class to all instances provided by the registrations associated with it.
If the class is not registered, but it is decorated with AutoRegister, or ContainerOptions.autoRegister is true, the class is registered automatically. Otherwise, the resolution fails.
The scope for the automatic registration is determined by either the Scoped decorator on the class, or ContainerOptions.defaultScope.
If the class is not registered in this container or any of its parent containers and could not be auto-registered, an empty array is returned instead.
The resolution behavior depends on the Provider used during registration:
If the class is registered with Container scope, the resolved instances are cached in the container's internal registry.
A separate instance of the class is created for each provider.
Resolves the given token to all values provided by the registrations associated with it.
If the token is not registered in this container or any of its parent containers, an empty array is returned instead.
The resolution behavior depends on the Provider used during registration:
If the token is registered with Container scope, the resolved values are cached in the container's internal registry.
Removes all registrations for the given token from the container's internal registry.
Returns an array of the distinct values that were cached by this container for the removed registrations. Values from ValueProvider registrations are not included, as they are not cached.
Note that only this container is affected. Parent or child containers, if any, remain unchanged.
A Dependency Injection container.