UNPKG

@wizecorp/stratusjs

Version:
45 lines 1.45 kB
import type { Service, ServiceContainer as IServiceContainer, ServiceConstructor } from './types'; /** * Dependency injection container for services */ export declare class ServiceContainer implements IServiceContainer { private services; private factories; private singletons; private initializing; /** * Register a service or factory in the container */ register<T extends Service>(token: string | symbol | ServiceConstructor<T>, serviceOrFactory: T | (() => T | Promise<T>), options?: { singleton?: boolean; }): void; /** * Get a service synchronously */ get<T extends Service>(token: string | symbol | ServiceConstructor<T>): T; /** * Get a service asynchronously (supports async factories) */ getAsync<T extends Service>(token: string | symbol | ServiceConstructor<T>): Promise<T>; /** * Check if a service is registered */ has(token: string | symbol | ServiceConstructor): boolean; /** * Remove a service from the container */ remove(token: string | symbol | ServiceConstructor): void; /** * Clear all services */ clear(): void; /** * Get all registered service tokens */ getTokens(): (string | symbol | ServiceConstructor)[]; /** * Check if value is a service instance (has name property) */ private isServiceInstance; } //# sourceMappingURL=ServiceContainer.d.ts.map