@eclipse-emfcloud/model-service-theia
Version:
Model service Theia
52 lines • 2.68 kB
TypeScript
import { ProviderChangeListener } from '@eclipse-emfcloud/model-accessor-bus';
import { ModelAccessorBusProtocol, ProviderChangeSubscriptionToken } from '../common';
import { FrontendModelAccessorBusSubscriber } from './frontend-model-accessor-bus-subscriber';
export declare const FrontendModelAccessorBus: unique symbol;
/**
* A {@link ModelAccessorBus} projected from the Theia backend in which all
* of its methods are asynchronous over the RPC channel. This
* frontend model accessor bus can be used in the frontend exactly as the
* Model Accessor Bus would be in the backend, except that it does not
* provide access to backend-only capabilities such as:
*
* - register a provider
* - unregister a provider
*
* It allows to subscribe and unsubscribe to notifications from providers and accessors.
*/
export interface FrontendModelAccessorBus {
/**
* Subscribe to model accessor bus notifications.
*
* @param accessorId the accessor ID to which to subscribe, or * to subscribe to all providers/accessors
*/
subscribe(accessorId: string, onAccessorChanged: (id: string) => void): Promise<ProviderChangeSubscriptionToken>;
/**
* Unsubscribe to a model accessor bus subscription.
*
* @param subscriptionId A number identifying a unique subscription to close
*/
unsubscribe(subscriptionId: number): void;
/**
* Calls an accessor through the {@link ModelAccessorBusProtocol}.
*
* @param {string} accessorId The string uniquely identifying the accessor.
* @param {array} parameters An optional list of parameters. The expected list of parameters depends on the accessor.
* @returns undefined if the accessor has not been found. Depending on its implementation, an accessor may return undefined as well.
* @throws if the list of provided arguments does not match the accessor requirements.
*/
get<T>(accessorId: string, ...parameters: unknown[]): Promise<T | undefined>;
}
export declare class FrontendModelAccessorBusImpl implements FrontendModelAccessorBus {
protected readonly modelAccessorBusProtocol: ModelAccessorBusProtocol;
protected readonly delegate: FrontendModelAccessorBusSubscriber;
/**
* Model Hub Context provided by the parent {@link FrontendModelHub}.
*/
protected context: string;
setContext(newContext: string): void;
unsubscribe(subscriptionId: number): void;
subscribe(providerId: string, onAccessorChanged: ProviderChangeListener): Promise<ProviderChangeSubscriptionToken>;
get<T>(accessorId: string, ...parameters: unknown[]): Promise<T | undefined>;
}
//# sourceMappingURL=frontend-model-accessor-bus.d.ts.map