UNPKG

@rokkit.ts/dependency-injection

Version:

TypeScript dependency injection library using decorators for the rokkit.ts framework and other projects

36 lines (35 loc) 1.75 kB
import { InjectorConstructorArgument } from '..'; /** * @class RokkitDI * This class exposes the API to register Injectables on the dependencies container. * The container is maintained as a singleton, so that all module of your application use the same container nad get the same injectors. * In order to retrieve an instance you can decide if you want to get an singleton or a new instance. */ declare class DependencyInjectionContainer { private readonly injectables; private readonly instances; registerInjectable<T extends object>(classConstructor: new (...args: any[]) => T, classConstructorArguments?: any[] | InjectorConstructorArgument[]): DependencyInjectionContainer; /** * @function singletonOf * This function let's you retrieve a registered intjector as a singleton object. That means * that each next call will get the exact same instances. * @param injectable:string Name of the class you want to retrieve * @returns any object that is already stored or we be create by the corresponding injector */ singletonOf(injectable: string): any; /** * @function instanceOf * This function let's you create new instance of the registered injector. * That means that every time you call this function you will retrieve a new object. * @param injectable:string Name of the class you want to retrieve * @returns any new object that is created by the corresponding injector */ instanceOf(injectable: string): any; private updateProvidedWithScannedArguments; private instantiateSingleton; private injectorFor; private instanctiateArgValues; private isUserObject; } export declare const RokkitDI: DependencyInjectionContainer; export {};