UNPKG

@triviality/core

Version:
76 lines (75 loc) 2.73 kB
import { ServiceFactory, ServiceTag, SF } from '../ServiceFactory'; import { ImmutableServiceReferenceList } from './ImmutableServiceReferenceList'; import { FeatureFactory, FF } from '../FeatureFactory'; import { ServiceFactoryReference } from './ServiceFactoryReference'; export interface ServiceFactoryReferenceOptions { readonly factory: SF; /** * The feature that created this service function. */ readonly feature: FF; } export interface ServiceFunctionReferenceConfiguration { /** * Unique identify this dependency with. This should * always be the same, should not be effected by async operations. */ readonly uuid: string; /** * The callback function proxy this service is referenced by. * * This allows that the actual service can be overriden. * * Dependency -> Service factory Proxy -> Actual service factory. */ readonly proxy: ServiceFactory<any>; } /** * Purpose is to hold information about a service function connection. * * TODO: Convert mayhem/inheritance, state machine classes. * The ideal world there is only 1 service factory reference for each service, now there are multiple. */ export declare abstract class BaseServiceFactoryReference { /** * All the dependencies this services is depended on. */ protected dependencies: ImmutableServiceReferenceList; /** * The actual service function reference. */ protected readonly factory: SF; /** * If the original service is invoked. */ protected serviceFactoryInvoked: boolean; /** * If the service factory created instance. */ protected serviceDefined: boolean; /** * The instance created by the service factory. */ protected service: unknown | undefined; /** * The feature that created this service function. */ protected readonly feature: FeatureFactory<any>; protected _configuration: ServiceFunctionReferenceConfiguration | null; constructor({ factory, feature }: ServiceFactoryReferenceOptions); get configuration(): ServiceFunctionReferenceConfiguration; getUuid(): string; callServiceFactory(thisReference: Record<ServiceTag, SF>): void; getService(): unknown; setContainerConfiguration(configuration: ServiceFunctionReferenceConfiguration): void; getFactory(): SF<any>; getFeature(): FF; getProxy(): SF<any>; hasServiceInstance(): boolean; addDependency(dependency: ServiceFactoryReference): void; getDependencies(): ImmutableServiceReferenceList; label(): string; protected assertServiceFunctionNotYetInvoked(): void; private assertNotYetConfigured; private assertHasServiceInstance; }