@xeito/injection
Version:
Dependency Injection for Xeito | Framework for building web applications
37 lines (32 loc) • 1.14 kB
TypeScript
declare class Registry {
/**
* Map with all the registered services
* @type {Map<string, any>}
*/
private static readonly serviceMap;
/**
* Register a service instance in the registry
* @param name name of the service
* @param service service instance
*/
static registerService(name: string, service: any): void;
/**
* Get a service instance from the registry
* @param name name of the service
* @returns service instance
* @throws {Error} if the service is not found
*/
static getService(name: string): any;
/**
* Checks if a service exists in the registry
* @param name name of the service
* @returns true if the service exists, false otherwise
*/
static serviceExists(name: string): boolean;
}
interface InjectableMetadata {
selector: string;
}
declare function Injectable(injectableMetadata: InjectableMetadata): (target: any) => void;
declare function Inject(serviceName?: string): (target: any, propertyKey: string) => void;
export { Inject, Injectable, InjectableMetadata, Registry };