import { IProvider } from "../interfaces/iprovider"; /** * @since 1.0.0 * @function * @name Injector * * @param {Injector} parent injector * * @description * Dependency injection for class injection * */ export declare class Injector { private parent; private _uid; private _name; private _providers; private _children; /** * @since 1.0.0 * @static * @function * @name Injector#createAndResolveChild * @param {Injector} parent * @param {Function} Class * @param {Array} providers * @return {Injector} instance * * @description * Static method which creates child injector on current injector and creates instance of Injectable class * * @example * \@Injectable() * class MyInjectableClass{ * \@Inject("config") * private config: Object; * } * * let parent = new Injector(); * let injector = Injector.createAndResolveChild( * parent, * MyInjectableClass, * [ * {provide: "config", useValue: {id: 1, message: "This is custom provider for injector"}} * ] * ); * let myInstance = injector.get(MyInjectableClass); */ static createAndResolveChild(parent: Injector, Class: IProvider | Function, providers: Array): Injector; /** * @since 1.0.0 * @static * @function * @name Injector#createAndResolve * @param {Function} Class * @param {Array} providers * @return {Injector} instance * * @description * Static method which creates injector and instance of Injectable class * * @example * \@Injectable() * class MyInjectableClass{ * \@Inject("config") * private config: Object; * } * * let injector = Injector.createAndResolve( * MyInjectableClass, * [ * {provide: "config", useValue: {id: 1, message: "This is custom provider for injector"}} * ] * ); * let myInstance = injector.get(MyInjectableClass); */ static createAndResolve(Class: IProvider | Function, providers: Array): Injector; /** * @since 1.0.0 * @constructor * @function * @name Injector#constructor * @param {Injector} parent * @param {Array} keys which are mutable * * @description * Injector constructor */ constructor(parent?: Injector, keys?: Array); /** * @since 1.0.0 * @function * @name Injector#createAndResolve * @param {IProvider} provider * @param {Array} providers * * @description * Creates instance of verified provider and creates instances of current providers and assign it to current injector instance * This method is used internally in most cases you should use static method Injector.createAndResolve or Injector.createAndResolveChild */ createAndResolve(provider: IProvider, providers: Array): any; /** * @since 1.0.0 * @function * @name Injector#destroy * * @description * Do cleanup on current injector and all children so we are ready for gc this is used internally by framework */ destroy(): void; /** * @since 1.0.0 * @function * @name Injector#has * @param {any} key * * @description * Check if Injectable class has instance on current injector */ has(key: any): boolean; /** * @since 1.0.0 * @function * @name Injector#get * @param {any} provider * @param {IProvider} Class * * @description * Gets current Injectable instance throws exception if Injectable class is not created */ get(provider: any, Class?: IProvider): any; /** * @since 1.0.0 * @function * @name Injector#set * @param {any} key * @param {Object} value * * @description * Sets Injectable instance to current injector instance */ set(key: any, value: Object): void; /** * @since 1.0.0 * @function * @name Injector#getId * @private * * @description * Get injector id */ getId(): string; /** * @since 1.0.0 * @function * @name Injector#setName * @private * * @description * Set injector name */ setName(provider: IProvider): void; /** * @since 1.0.0 * @function * @name Injector#setChild * @param {Injector} injector * @private * * @description * Append child Injector */ private setChild(injector); /** * @since 1.0.0 * @function * @name Injector#setChild * @param {Injector} injector * @private * * @description * Remove child injector */ private removeChild(injector); }