import { AsyncFactory, BindAs, OnErrorCallback, OnSuccessCallback, SyncFactory } from './binding'; import { ClassConstructor, InjectableId, Injector } from './injector'; import { Provider } from './provider'; /** * @inheritDoc * This abstraction is for Providers that can be additionally configured as Singletons and/or configured with error and/or success handling callback(s). */ export declare abstract class BindableProvider | SyncFactory | AsyncFactory> extends Provider { protected injector: Injector; protected id: InjectableId; protected maker: M; protected constructor(injector: Injector, id: InjectableId, maker: M); /** * A user supplied success handling function. * Default value is undefined. */ protected successHandler?: OnSuccessCallback; /** * A user supplied error handling function. * Default value is undefined. */ protected errorHandler?: OnErrorCallback; /** * Invoked by the Container to create chain-able configuration * * @see BindAs */ makeBindAs(): BindAs; /** * Encapsulate the logic of invoking any configured error handler, and processing it's result. * * @see OnErrorCallback * * @returns The object substituted by the callback (otherwise this method throws the appropriate error). */ protected queryErrorHandler(err: unknown, obj?: T): T; /** * This is like a retry mechanism that uses the Provider's errorHandler (if any) to attempt recovery whenever the supplied Promise rejects. * This method returns a Promise that rejects if recovery was not possible. * If the supplied Promise resolves, then this method passes the result to the callback, and then resolve as whatever that callback returns. * * @param waitFor The supplied Promise. * @param cb Callback to be invoked if the supplied Promise resolves. */ protected makePromiseForObj(waitFor: Promise, cb: (result: R) => T): Promise; }