async-injection
Version:
A robust lightweight dependency injection library for TypeScript.
38 lines (37 loc) • 1.65 kB
TypeScript
import { BindableProvider } from './bindable-provider.js';
import { ClassConstructor, InjectableId, Injector } from './injector.js';
import { State } from './state.js';
interface StateResolvingInjector extends Injector {
resolveState<T>(id: InjectableId<T>): State<T>;
}
/**
* @inheritDoc
* This specialization invokes it's configured class constructor synchronously and then scans for (and invokes) any @PostConstruct (which may be synchronous or asynchronous).
*/
export declare class ClassBasedProvider<T> extends BindableProvider<T, ClassConstructor<T>> {
constructor(injector: StateResolvingInjector, id: InjectableId<T>, maker: ClassConstructor<T>);
/**
* @inheritDoc
* @see the class description for this Provider.
* This method is just a singleton guard, the real work is done by provideAsStateImpl.
*/
provideAsState(): State<T>;
/**
* @inheritDoc
* This specialization returns undefined if 'asyncOnly' is true and there is no asynchronous PostConstruct annotation (since class constructors can never by asynchronous).
*/
resolveIfSingleton(asyncOnly: boolean): Promise<T>;
/**
* Make a resolved or pending State that reflects any @PostConstruct annotations.
*/
protected makePostConstructState(obj: T): State<T>;
/**
* This method collects the States of all the constructor parameters for our target class.
*/
protected getConstructorParameterStates(): State[];
/**
* Gather the needed constructor parameters, invoke the constructor, and figure out what post construction needs done.
*/
private provideAsStateImpl;
}
export {};