@omnia/fx
Version:
Provide Omnia Fx typings and tooling for clientside Omnia development.
25 lines (24 loc) • 1.49 kB
TypeScript
/**
* Inject an instance of the specifed type. That instance can pass down to childrens in ui relationship.
*
* @param classType - Type to inject
* @param constructorArgs - Optional arguments for the constructor, by naming convention an interface should be supplied specifying the expected parameters
* the name of the interface should follow <classType>Constructor i.e.
* Type: HttpClient, if supporting constructor arguments an interface named: "HttpClientConstructor" should be supplied.
*
* E.g.:
* Provide<HttpClientConstructor>(HttpClient,{someConstructorArg1:"",someConstructorArg2})
*/
export declare function Provide<T>(classType: any, constructorArgs?: T): any;
/**
* Provide an instance of the specifed type. That instance will available to lower level inject it.
*
* @param provide - Type to inject
* @param constructorArgs - Optional arguments for the constructor, by naming convention an interface should be supplied specifying the expected parameters
* the name of the interface should follow <classType>Constructor i.e.
* Type: HttpClient, if supporting constructor arguments an interface named: "HttpClientConstructor" should be supplied.
*
* E.g.:
* useInject<HttpClientConstructor>(HttpClient,{someConstructorArg1:"",someConstructorArg2})
*/
export declare function useProvide<TProvide, TConstructor>(provide: TProvide, constructorArgs?: TConstructor): TProvide extends new (...args: any) => infer P ? P : TProvide extends Object ? TProvide : never;