UNPKG

@amo-tm/wsc

Version:

The amo WSC component of the amo JS SDK

35 lines (34 loc) 1.33 kB
import { Name, NameServiceMapping } from './types'; import { ComponentContainer } from './component-container'; import { Component } from './component'; /** * Provider for instance for service name T, e.g. 'wsc', 'wsc-connector-internal' * NameServiceMapping[T] is an alias for the type of the instance */ export declare class Provider<T extends Name> { private readonly name; private readonly container; private component; private readonly instances; private readonly instancesDeferred; constructor(name: T, container: ComponentContainer); get(): Promise<NameServiceMapping[T]>; /** * * @param options.optional If optional is false or not provided, the method throws an error when * the service is not immediately available. * If optional is true, the method returns null if the service is not immediately available. */ getImmediate(options: { optional: true; }): NameServiceMapping[T] | null; getImmediate(options?: { optional?: false; }): NameServiceMapping[T]; setComponent(component: Component<T>): void; isComponentSet(): boolean; isInitialized(identifier?: string): boolean; private getOrInitializeService; private normalizeInstanceIdentifier; private shouldAutoInitialize; }