UNPKG

@awesome-nodes/mvvm

Version:

Application development framework using the *model* *view* *view-model* design pattern.

39 lines (38 loc) 1.74 kB
import { ClassProviderConfig, FactoryProviderConfig, Token } from '@awesome-nodes/injection-factory'; import { ObjectBase } from '@awesome-nodes/object'; import { ServiceBase } from "../services"; import { ConstructorFunction } from 'simplytyped'; /** * Configures the factory provider to return the service factory configuration. */ export interface IServiceProvider { /** * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`). */ provide?: ConstructorFunction<object>; /** * A list of `token`s which need to be resolved by the injector. The list of values is then * used as arguments to the `useFactory` function. */ deps?: Array<Token>; } /** * Represents the base object for the provider in the service provider pattern. */ export declare abstract class ServiceProviderBase<T extends ServiceBase<unknown>> extends ObjectBase { abstract get designFactory(): IServiceProvider; abstract get developmentFactory(): IServiceProvider; abstract get productionFactory(): IServiceProvider; provide(provide: ConstructorFunction<T>): T; abstract inject(provider: FactoryProviderConfig<T>): T; /** * Returns the factory configuration provided by a derived provider type on which this function was invoked on. * @param provide * @param provider */ static createFactoryProvider<U extends ServiceBase<unknown>>(provide: ConstructorFunction<U>, provider?: ServiceProviderBase<U>): FactoryProviderConfig<U>; /** * Returns the staging configuration provided by the type on which this function was invoked on. */ static createClassProvider<U extends ServiceBase<unknown>>(): ClassProviderConfig<U>; }