@triviality/core
Version:
Purely typed service container
18 lines (17 loc) • 1.46 kB
TypeScript
import { ServiceFactoryByTag, ServiceKeysOfType, SF } from '../../ServiceFactory';
import { REGISTER_LIST_ARGUMENTS, RegistryList } from './ImmutableRegistryList';
import { ServiceFunctionReferenceContainerInterface } from '../../Container/ServiceFunctionReferenceContainerInterface';
export declare type RegisterListArgument<Services, TType> = ServiceKeysOfType<Services, TType> | SF<TType>;
export declare type RegisterListArguments<Services, TType> = RegisterListArgument<Services, TType>[];
export interface RegistryListContext<T> {
registerList<TType>(...items: RegisterListArguments<T, TType>): SF<RegistryList<TType>>;
}
export declare type RegisterWithListArguments<T, TType> = (...items: RegisterListArguments<T, TType>) => {};
export declare type InferListArgumentRegisters<T> = {
[K in keyof T]: T[K] extends {
[REGISTER_LIST_ARGUMENTS]: infer TType;
} ? RegisterWithListArguments<T, TType> : unknown;
};
export declare const createFeatureFactoryRegistryListContext: <T>(container: ServiceFunctionReferenceContainerInterface<any>) => RegistryListContext<T>;
export declare const getServices: <Services, T>(getService: ServiceFactoryByTag<T>) => (...items: RegisterListArguments<Services, T>) => import("../../ServiceFactory").ServiceFactory<T>[];
export declare function registerList<Services, T>({ getService }: ServiceFunctionReferenceContainerInterface): (...items: RegisterListArguments<Services, T>) => SF<RegistryList<T>>;