import { BindableProvider } from './bindable-provider'; import { ClassConstructor, InjectableId, Injector } from './injector'; import { State } from './state'; interface StateResolvingInjector extends Injector { resolveState(id: InjectableId): State; } /** * @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 extends BindableProvider> { constructor(injector: StateResolvingInjector, id: InjectableId, maker: ClassConstructor); /** * @inheritDoc * @see the class description for this Provider. * This method is just a singleton guard, the real work is done by provideAsStateImpl. */ provideAsState(): State; /** * @inheritDoc * This specialization returns undefined if 'asyncOnly' is true **and** there is no asynchronous PostConstruct annotation (since class constructors can never by asynchronous), * **unless** the @PostConstruct method has injectable parameters, which may themselves require async resolution. */ resolveIfSingleton(asyncOnly: boolean): Promise | undefined; /** * Returns true if the @PostConstruct method (if any) has at least one parameter. * Any parameter may require async resolution, so this class must participate in resolveSingletons. */ private postConstructHasParams; /** * Make a resolved or pending State that reflects any @PostConstruct annotations and/or onSuccess handler. * Any @PostConstruct method (with any injected parameters) runs first; the onSuccess handler runs after. */ protected makePostConstructState(obj: T): State; /** * Collects the resolved States for all injectable parameters of a @PostConstruct method. * Uses the same resolution rules as constructor parameters: the reflected type (or an explicit @Inject token) is used to look up the binding, and an error is thrown if the type cannot be determined. * Use @Optional() on a parameter to supply a fallback when no binding is found. * Returns an empty array if the method has no parameters. */ protected getMethodParameterStates(ctor: Function, methodName: string): State[]; /** * 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 {};