UNPKG

@elsikora/cladi

Version:

ClaDI is a library for creating and managing classes in TypeScript.

49 lines 1.64 kB
import type { IFactory } from '../../../domain/interface/index'; import type { IRegistry } from '../../../domain/interface/index'; import type { IBaseFactoryOptions } from '../../interface/index'; /** * Generic factory implementation that creates items by name using a registry as data source. * @template T The type of items created by the factory. * @see {@link https://elsikora.com/docs/cladi/core-concepts/factory} */ export declare class BaseFactory<T> implements IFactory<T> { /** * Internal cache of created items. */ private readonly CACHE; /** * Logger instance. */ private readonly LOGGER; /** * Registry instance. */ private readonly REGISTRY; /** * Optional custom transformer function. */ private readonly TRANSFORMER?; /** * Create a new factory instance. * @param {IBaseFactoryOptions<T>} options Factory options. */ constructor(options: IBaseFactoryOptions<T>); /** * Clear all cached items or a specific cached item. * @param {string} [name] Optional name of specific cached item to clear. */ clearCache(name?: string): void; /** * Create an item by name. * @param {string} name The name of the item to create. * @returns {T} The created item. * @throws RegistryItemNotFoundError if no item with the given name exists in the registry. */ create(name: string): T; /** * Get the registry associated with this factory. * @returns {IRegistry<T>} The registry instance. */ getRegistry(): IRegistry<T>; } //# sourceMappingURL=factory.class.d.ts.map