@elsikora/cladi
Version:
ClaDI is a library for creating and managing classes in TypeScript.
68 lines • 2.69 kB
TypeScript
import type { IContainer } from '../../../domain/interface/index';
import type { IBaseContainerOptions } from '../../interface/index';
/**
* Simple dependency injection container implementation.
* @see {@link https://elsikora.com/docs/cladi/core-concepts/container}
*/
export declare class BaseContainer implements IContainer {
private readonly DEPENDENCIES;
private readonly LOGGER;
/**
* Create a new container.
* @param {IBaseContainerOptions} options - The options to use for the container.
*/
constructor(options: IBaseContainerOptions);
/**
* Clear all dependencies from the container.
*/
clear(): void;
/**
* Get a dependency from the container.
* @param {symbol} token Token that identifies the dependency.
* @returns {T | undefined} The dependency, or undefined if it doesn't exist.
* @template T The type of the dependency.
*/
get<T>(token: symbol): T | undefined;
/**
* Get all dependencies from the container.
* @returns {Array<unknown>} An array of all dependencies.
*/
getAll(): Array<unknown>;
/**
* Get multiple dependencies from the container.
* @param {Array<symbol>} tokens Tokens that identify the dependencies.
* @returns {Array<unknown>} An array of dependencies.
*/
getMany<T>(tokens: Array<symbol>): Array<T>;
/**
* Check if a dependency exists in the container.
* @param {symbol} token Token that identifies the dependency.
* @returns {boolean} True if the dependency exists, false otherwise.
*/
has(token: symbol): boolean;
/**
* Register a dependency in the container.
* @param {symbol} token Token that identifies the dependency.
* @param {T} implementation Implementation of the dependency.
* @template T The type of the dependency.
*/
register(token: symbol, implementation: unknown): void;
/**
* Register multiple dependencies in the container.
* @param {Array<symbol>} tokens Tokens that identify the dependencies.
* @param {Array<T>} implementations Implementations of the dependencies.
* @template T The type of the dependencies.
*/
registerMany(tokens: Array<symbol>, implementations: Record<symbol, unknown>): void;
/**
* Remove a dependency from the container.
* @param {symbol} token Token that identifies the dependency.
*/
unregister(token: symbol): void;
/**
* Remove multiple dependencies from the container.
* @param {Array<symbol>} tokens Tokens that identify the dependencies.
*/
unregisterMany(tokens: Array<symbol>): void;
}
//# sourceMappingURL=container.class.d.ts.map