@akala/core
Version:
44 lines (43 loc) • 2.29 kB
TypeScript
export declare type Injected<T> = (instance?: any) => T;
export declare type Injectable<T> = (...args: any[]) => T;
export declare type InjectableWithTypedThis<T, U> = (this: U, ...args: any[]) => T;
export declare type InjectableAsync<T> = (...args: any[]) => PromiseLike<T>;
export declare type InjectableAsyncWithTypedThis<T, U> = (this: U, ...args: any[]) => PromiseLike<T>;
export declare class Injector {
protected parent?: Injector;
constructor(parent?: Injector);
private notifier;
setInjectables(value: {
[key: string]: any;
}): void;
keys(): string[];
merge(i: Injector): void;
protected notify<T>(name: string, value?: PropertyDescriptor): void;
onResolve<T = any>(name: string): PromiseLike<T>;
onResolve<T = any>(name: string, handler: (value: T) => void): void;
inject<T>(a: Injectable<T>): Injected<T>;
inject<T>(...a: string[]): (b: TypedPropertyDescriptor<Injectable<T>>) => void;
inject<T>(a: Injectable<T> | string, ...b: string[]): Injected<T> | ((b: TypedPropertyDescriptor<Injectable<T>>) => void);
injectAsync<T>(a: Injectable<T>): any;
injectAsync<T>(...a: string[]): any;
injectNew<T>(ctor: Injectable<T>): Injected<unknown>;
resolve<T = any>(param: string): T;
resolveAsync<T = any>(name: string): T | PromiseLike<T>;
private inspecting;
inspect(): void;
private browsingForJSON;
toJSON(): {};
injectNewWithName(toInject: string[], ctor: Function): Injected<unknown>;
injectWithNameAsync<T>(toInject: string[], a: InjectableAsync<T> | Injectable<T>): PromiseLike<T>;
injectWithName<T>(toInject: string[], a: Injectable<T>): Injected<T>;
exec<T>(...toInject: string[]): (f: Injectable<T>) => T;
private injectables;
unregister(name: string): void;
register<T>(name: string, value: T, override?: boolean): T;
registerFactory<T>(name: string, value: () => T, override?: boolean): () => T;
factory(name: string, override?: boolean): <T>(fact: () => T) => () => T;
service(name: string, ...toInject: string[]): any;
service(name: string, override?: boolean, ...toInject: string[]): any;
registerDescriptor(name: string, value: PropertyDescriptor, override?: boolean): void;
}
export declare var defaultInjector: Injector;