/******************************************************************************** * Copyright (c) 2017-2018 TypeFox and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ import { Action, RequestAction, ResponseAction } from 'sprotty-protocol/lib/actions'; import { Deferred } from 'sprotty-protocol/lib/utils/async'; import { ILogger } from '../../utils/logging'; import { ICommandStack } from '../commands/command-stack'; import { AnimationFrameSyncer } from '../animations/animation-frame-syncer'; import { ActionHandlerRegistry } from './action-handler'; import { IDiagramLocker } from './diagram-locker'; export interface IActionDispatcher { dispatch(action: Action): Promise; dispatchAll(actions: Action[]): Promise; request(action: RequestAction): Promise; } /** * Collects actions, converts them to commands and dispatches them. * Also acts as the proxy to model sources such as diagram servers. */ export declare class ActionDispatcher implements IActionDispatcher { protected actionHandlerRegistryProvider: () => Promise; protected commandStack: ICommandStack; protected logger: ILogger; protected syncer: AnimationFrameSyncer; protected diagramLocker: IDiagramLocker; protected actionHandlerRegistry: ActionHandlerRegistry; protected initialized: Promise | undefined; protected blockUntil?: (action: Action) => boolean; protected postponedActions: PostponedAction[]; protected readonly requests: Map>; initialize(): Promise; /** * Dispatch an action by querying all handlers that are registered for its kind. * The returned promise is resolved when all handler results (commands or actions) * have been processed. */ dispatch(action: Action): Promise; /** * Calls `dispatch` on every action in the given array. The returned promise * is resolved when the promises of all `dispatch` calls have been resolved. */ dispatchAll(actions: Action[]): Promise; /** * Dispatch a request. The returned promise is resolved when a response with matching * identifier is dispatched. That response is _not_ passed to the registered action * handlers. Instead, it is the responsibility of the caller of this method to handle * the response properly. For example, it can be sent to the registered handlers by * passing it again to the `dispatch` method. */ request(action: RequestAction): Promise; protected handleAction(action: Action): Promise; protected handleBlocked(action: Action, predicate: (action: Action) => boolean): Promise; } export interface PostponedAction { action: Action; resolve: () => void; reject: (reason: any) => void; } export type IActionDispatcherProvider = () => Promise; //# sourceMappingURL=action-dispatcher.d.ts.map