UNPKG

@symanticreative/vendure-admin-client

Version:

A TypeScript GraphQL client for Vendure Admin API to create custom dashboards

57 lines (56 loc) 1.54 kB
/** * Simple dependency injection container * Manages service instances and dependencies */ export declare class Container { private static instance; private services; private factories; /** * Get the singleton instance of the container */ static getInstance(): Container; /** * Register a service instance * @param token - Service identifier/token * @param instance - Service instance */ register<T>(token: string, instance: T): void; /** * Register a factory function to create a service * @param token - Service identifier/token * @param factory - Factory function to create the service */ registerFactory<T>(token: string, factory: () => T): void; /** * Get a service instance * If not found, attempts to create it using registered factory * @param token - Service identifier/token */ get<T>(token: string): T; /** * Check if a service is registered * @param token - Service identifier/token */ has(token: string): boolean; /** * Remove a service instance * @param token - Service identifier/token */ remove(token: string): void; /** * Clear all registered services */ clear(): void; } /** * Type for service tokens to prevent magic strings */ export type ServiceToken<T> = string & { __type: T; }; /** * Create a typed service token * @param name - Token name */ export declare function createServiceToken<T>(name: string): ServiceToken<T>;