UNPKG

servido

Version:

Versatile services for React ⚗️

10 lines (9 loc) 1.01 kB
import { Service, ServiceQuery } from "./service"; /** If the service accepts arguments, those can be passed as additional arguments to the hook. Whenever the passed service or arguments change, a new instance may or may not be constructed. * If an instance of the service has been provided by a parent using `ServiceProvider`, that instance will be preferred unless there is a mismatch of arguments. */ export declare function useService<S extends Service>(service: ServiceQuery<S, [], any[]>): S; export declare function useService<S extends Service, QA extends any[]>(service: ServiceQuery<S, [], QA>): S; export declare function useService<S extends Service, A extends any[], QA extends any[]>(service: ServiceQuery<S, A, QA>, ...arguments_: A): S; /** Check if any of the passed services are currently constructing and react to when the construction resolves. * The passed services must always be of the same length. */ export declare function useConstructing(...services: Service[]): boolean;