UNPKG

servido

Version:

Versatile services for React ⚗️

18 lines (17 loc) 1.06 kB
import { Service, ServiceQuery } from "./service"; import { ServiceDependent } from "./service-dependent"; import { ServiceIdentifier } from "./service-types"; /** Create a dependency of the `service`. If the service accepts arguments, those can be passed using the `args` prop. If no arguments are passed or if there * has already been a constructed instance with the same identifiable arguments, that will be preferred over constructing a new instance. */ export declare function requireService<S extends Service, A extends any[]>(props: RequireServiceProps<S, A>): S; export declare function requireService<S extends Service>(props: RequireServiceProps<S, []>): S; export interface RequireServiceProps<S extends Service, A extends any[]> { /** The service */ service: ServiceQuery<S, A>; dependent: ServiceDependent; args?: A; /** If the service has definitely already been constructed, an identifier can be passed. */ id?: ServiceIdentifier; } export declare class CircularDependencyError extends RangeError { }