command-service.ts 591 B

123456789101112131415161718192021222324
  1. import { type Disposable, type Event } from '@flowgram.ai/utils';
  2. import { type CommandEvent } from './command';
  3. export const CommandService = Symbol('CommandService');
  4. /**
  5. * command service 执行接口
  6. */
  7. export interface CommandService extends Disposable {
  8. /**
  9. * command 事件执行前触发事件
  10. */
  11. readonly onWillExecuteCommand: Event<CommandEvent>;
  12. /**
  13. * command 事件执行完成后触发
  14. */
  15. readonly onDidExecuteCommand: Event<CommandEvent>;
  16. /**
  17. * 执行 command
  18. */
  19. executeCommand<T>(command: string, ...args: any[]): Promise<T | undefined>;
  20. }