UNPKG

dependency-injection-cat

Version:

DI Cat is a truly clean DI-container, which allows you not to pollute your business logic with decorators from DI/IOC libraries!

39 lines (37 loc) 1.36 kB
export declare type TBeanName = string; export declare type TLifecycle = "post-construct" | "before-destruct"; export declare type TLifecycleConfiguration = Record<TLifecycle, TBeanName[]>; export interface IFullBeanConfig { scope?: "prototype" | "singleton"; isPublic?: boolean; } export interface IInternalCatContext { config: any; getBean<T>(beanName: string): T; getBeans(): Record<string, any>; ___postConstruct(): void; ___beforeDestruct(): void; } export declare type TInternalCatContext = { new (contextName: string, beanConfigurationRecord: Record<string, IFullBeanConfig>, lifecycleConfiguration: TLifecycleConfiguration): IInternalCatContext; }; export interface IContextProps { key: any; config: any; } export declare type TBeanName = string; export declare class ContextPool { private contextName; private beanConfigurationRecord; private lifecycleConfiguration; private context; private DEFAULT_CONTEXT_KEY; private pool; constructor(contextName: string, beanConfigurationRecord: Record<TBeanName, IFullBeanConfig>, lifecycleConfiguration: TLifecycleConfiguration, context: TInternalCatContext); initContext({ key, config, }: IContextProps): any; getContext({ key }: IContextProps): any; getOrInitContext({ key, config, }: IContextProps): any; clearContext({ key }: IContextProps): void; private isDefaultKey; } export {};