@analog-tools/inject
Version:
Dependency injection for AnalogJS server-side applications
36 lines (35 loc) • 1.21 kB
TypeScript
import { ServiceRegistry } from './service-registry';
import { InjectionServiceClass, InjectOptions } from './inject.types';
export declare class InjectionContext {
private static contexts;
private static defaultScope;
/**
* Get or create a registry for the specified scope
*/
static getRegistry(scope?: string): ServiceRegistry;
/**
* Create a new scope with its own registry
*/
static createScope(scope: string): ServiceRegistry;
/**
* Destroy a scope and cleanup its services
*/
static destroyScope(scope: string): Promise<void>;
/**
* Set the default scope for injection operations
*/
static setDefaultScope(scope: string): void;
/**
* Get all active scopes
*/
static getActiveScopes(): string[];
/**
* Clear all scopes (useful for testing)
*/
static clearAll(): Promise<void>;
}
/**
* Scoped injection functions
*/
export declare function injectScoped<T>(token: InjectionServiceClass<T>, scope?: string, options?: InjectOptions): T;
export declare function registerServiceScoped<T, Args extends any[]>(token: InjectionServiceClass<T, Args>, scope?: string, ...properties: Args): void;