servido
Version:
Versatile services for React ⚗️
24 lines (23 loc) • 1.28 kB
TypeScript
import React from "react";
import { Service, ServiceClass, ServiceQuery } from "./service";
/** Allows for providing a specific set of default arguments for a service. */
export declare function ServiceProvider<S extends Service>(props: React.PropsWithChildren<ServiceProviderProps<S>>): JSX.Element;
export declare function ServiceProvider<S extends Service, A extends any[]>(props: React.PropsWithChildren<ServiceProviderPropsWithArgs<S, A>>): JSX.Element;
export interface ServiceProviderProps<S extends Service> {
/** The service to provide. */
service: ServiceQuery<S>;
/** If a query for the `proxy` should be redirected to the specified `service`. */
proxy?: ServiceQuery<S>;
/** If a query for any of the `proxies` should be redirected to the specified `service`. */
proxies?: ServiceQuery<S>[];
deps?: readonly any[];
}
export interface ServiceProviderPropsWithArgs<S extends Service, A extends any[]> {
service: ServiceClass<S, A>;
args?: A;
/** If a query for the `proxy` should be redirected to the specified `service`. */
proxy?: ServiceQuery<S>;
/** If a query for any of the `proxies` should be redirected to the specified `service`. */
proxies?: ServiceQuery<S>[];
deps?: readonly any[];
}