UNPKG

@eclipse-glsp/client

Version:

A sprotty-based client for GLSP

59 lines 2.74 kB
import { Action, Deferred, Disposable, Emitter } from '@eclipse-glsp/sprotty'; /** * The constraint defining when the initialization of the GLSP model is completed. * * Many actions, such as the `CenterAction`, can only be successfully processed if * the GLSP model initialization is completed, that is, the model has been set, * its bounds have been computed, the canvas bounds are available, etc. * * An injectable implementation of this constraint will be used by the * `GLSPActionDispatcher` to determine when the initialization is completed. * The action dispatcher therefore provides a promise via `onceInitialized()` * to trigger clients that want to dispatch an action, once the initialization * is done. * * For most of the cases `DefaultInitializationConstraint` can be used. In fact, * it is bound by default. However, custom implementations can rebind other * implementations of this constraint to, for instance, delay further before the * `onceInitialized()` promise is fulfilled by the `GLSPActionDispatcher`. */ export declare abstract class ModelInitializationConstraint { protected completion: Deferred<void>; protected _isCompleted: boolean; get isCompleted(): boolean; protected onInitializedEmitter: Emitter<void>; /** * Register a listener that will be invoked once the initialization process * has been completed. If the initialization is already completed on registration * the given listener will be invoked right away * @param listener */ onInitialized(listener: () => void): Disposable; /** * Retrieve a promise that resolves once the initialization process * has been completed. * @returns the initialization promise */ onInitialized(): Promise<void>; protected setCompleted(): void; notifyDispatched(action: Action): void; /** * Central method to check the initialization state. Is invoked * for every action dispatched by the `ActionDispatcher` (until the initialization has completed). * Should * return `true` once the action has been passed which marks the end * of the initialization process. * @param action The last dispatched action */ abstract isInitializedAfter(action: Action): boolean; } /** * Default initialization constraint triggers after a non-empty `UpdateModelAction` * and a subsequent `InitializeCanvasBoundsAction`. */ export declare class DefaultModelInitializationConstraint extends ModelInitializationConstraint { protected seenNonEmptyModelAction: boolean; isInitializedAfter(action: Action): boolean; protected isNonEmptyModelAction(action: Action): boolean; } //# sourceMappingURL=model-initialization-constraint.d.ts.map