UNPKG

@furystack/inject

Version:
46 lines 1.54 kB
import type { Constructable } from './models/constructable.js'; export declare class InjectorAlreadyDisposedError extends Error { constructor(); } export declare class CannotInstantiateExplicitLifetimeError extends Error { /** * */ constructor(ctor: Constructable<unknown>); } export declare class Injector implements AsyncDisposable { private isDisposed; /** * Disposes the Injector object and all its disposable injectables */ [Symbol.asyncDispose](): Promise<void>; /** * Options object for an injector instance */ options: { parent?: Injector; owner?: unknown; }; readonly cachedSingletons: Map<Constructable<unknown>, unknown>; remove: <T>(ctor: Constructable<T>) => void; getInstance<T>(ctor: Constructable<T>): T; /** * * @param ctor The constructor object (e.g. MyClass) * @returns The instance of the requested service */ private getInstanceInternal; /** * Sets explicitliy an instance for a key in the store * @param instance The created instance * @param key The class key to be persisted (optional, calls back to the instance's constructor) */ setExplicitInstance<T extends object>(instance: T, key?: Constructable<any>): void; /** * Creates a child injector instance * @param options Additional injector options * @returns the created Injector */ createChild(options?: Partial<Injector['options']>): Injector; } //# sourceMappingURL=injector.d.ts.map