UNPKG

@apiratorjs/di-container

Version:

A lightweight dependency injection container for JavaScript and TypeScript with powerful features: modular organization with DiModule.create, lazy initialization, automatic circular dependency detection, and multiple service lifecycles (singleton with bot

35 lines 1.56 kB
import { AsyncContextStore } from "@apiratorjs/async-context"; import { DiContainer } from "./di-container"; import { IDiConfigurator, IDiModule, ServiceToken, SingletonOptions, UseFactory } from "./types"; export declare class DiConfigurator implements IDiConfigurator { private _singletonServices; private _singletonServiceFactories; private _requestScopeServiceFactories; private _transientFactories; private _serviceMutexes; private _resolutionChains; private _registeredModules; addSingleton<T>(token: ServiceToken<any>, factory: UseFactory<T>, options?: SingletonOptions): this; disposeSingletons(): Promise<void>; addScoped<T>(token: ServiceToken<any>, factory: UseFactory<T>): this; addTransient<T>(token: ServiceToken<any>, factory: UseFactory<T>): this; addModule(module: IDiModule): this; resolve<T>(token: ServiceToken<T>): Promise<T>; runWithNewRequestScope(initialStore: AsyncContextStore, callback: () => Promise<any> | any): Promise<any>; getRequestScopeContext(): AsyncContextStore | undefined; isInRequestScopeContext(): boolean; build(): Promise<DiContainer>; /** * Lazy initializes and returns a singleton service. */ private tryGetSingleton; private tryGetScoped; private tryGetTransient; private disposeScopedServices; private getMutexFor; private getCurrentResolutionChain; private addToResolutionChain; private removeFromResolutionChain; private checkForCircularDependency; } //# sourceMappingURL=di-configurator.d.ts.map