UNPKG

@triviality/core

Version:
45 lines (44 loc) 1.89 kB
import { SF } from '../ServiceFactory'; import { ServiceFactoryReference } from '../Value/ServiceFactoryReference'; import { Override } from '../Value/Override'; import { ServiceFunctionReferenceContainerInterface } from './ServiceFunctionReferenceContainerInterface'; import { ImmutableServiceReferenceList } from '../Value/ImmutableServiceReferenceList'; export declare enum BuildingState { defineServices = 0, buildServices = 1, done = 2 } /** * Responsible for knowing about the wiring of the different services. * * The application only knows about references to a service, as function callback, ServiceReference, * for the end user this is named SF. * * - Protects the application of using the references for the application is fully done with * wiring everything. * - Stores the usage tree of the SF, as a dependency tree. */ export declare class ServiceFunctionReferenceContainer<Services = any> implements ServiceFunctionReferenceContainerInterface<Services> { getService: any; private state; private serviceReferences; private dependencyCallStack; /** * The global reference where all service functions are bound to, so * the 'this' keyword keeps working. */ private servicesReferences; references(): ImmutableServiceReferenceList; getCallStack(): ImmutableServiceReferenceList; /** * Return the actual referenced used by the application to fetch the service instance. * The first run it preserves a dependencyCallStack, to know the dependency tree. */ add<TService>(reference: ServiceFactoryReference, bound?: Record<string, import("../ServiceFactory").ServiceFactory<unknown>>): SF<TService>; build(): Promise<Services>; override<T>(override: Override<T>): this; private createUuid; private currentBuild; private assertBuildServices; private assertDefineServices; }