/** * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal */ import { PluginContext } from './context.js'; import { UUID } from '../mol-util/index.js'; export { PluginCommand, PluginCommandManager }; interface PluginCommand { (ctx: PluginContext, params?: T): Promise; readonly id: UUID; subscribe(ctx: PluginContext, action: PluginCommand.Action): PluginCommand.Subscription; } declare function PluginCommand(): PluginCommand; declare namespace PluginCommand { type Id = string & { '@type': 'plugin-command-id'; }; interface Subscription { unsubscribe(): void; } type Action = (params: T) => unknown | Promise; } declare class PluginCommandManager { private subs; private disposing; subscribe(cmd: PluginCommand, action: PluginCommand.Action): PluginCommand.Subscription; /** Resolves after all actions have completed */ dispatch(cmd: PluginCommand, params: T): Promise; dispose(): void; private resolve; }