Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CommandRegistry

The command registry manages commands and handlers.

Hierarchy

  • CommandRegistry

Implements

Index

Constructors

Properties

_commands: {} = {}

Type declaration

_handlers: {} = {}

Type declaration

_recent: Command[] = []
fireDidChange: ((...arguments: []) => Promise<void>) = ...

Type declaration

    • (...arguments: []): Promise<void>
    • Debounce promise-returning & async functions.

      example
      import pDebounce = require('p-debounce');

      const expensiveCall = async input => input;

      const debouncedFn = pDebounce(expensiveCall, 200);

      for (const i of [1, 2, 3]) {
      debouncedFn(i).then(console.log);
      }
      //=> 3
      //=> 3
      //=> 3

      Parameters

      • Rest ...arguments: []

      Returns Promise<void>

      A function that delays calling fn until after wait milliseconds have elapsed since the last time it was called.

onCommandsChanged: Event<void> = ...
onCommandsChangedEmitter: Emitter<void> = ...
onDidExecuteCommand: Event<CommandEvent> = ...
onDidExecuteCommandEmitter: Emitter<CommandEvent> = ...
onWillExecuteCommand: Event<WillExecuteCommandEvent> = ...
onWillExecuteCommandEmitter: Emitter<WillExecuteCommandEvent> = ...
toUnregisterCommands: Map<string, Disposable> = ...

Accessors

  • get commandIds(): string[]

Methods

  • clearCommandHistory(): void
  • doFireDidChange(): void
  • executeCommand<T>(commandId: string, ...args: any[]): Promise<undefined | T>
  • Execute the active handler for the given command and arguments.

    Reject if a command cannot be executed.

    Type Parameters

    • T

    Parameters

    • commandId: string
    • Rest ...args: any[]

    Returns Promise<undefined | T>

  • fireWillExecuteCommand(commandId: string, args?: any[]): Promise<void>
  • getActiveHandler(commandId: string, ...args: any[]): undefined | CommandHandler
  • getCommand(id: string): undefined | Command
  • getToggledHandler(commandId: string, ...args: any[]): undefined | CommandHandler
  • getVisibleHandler(commandId: string, ...args: any[]): undefined | CommandHandler
  • isEnabled(command: string, ...args: any[]): boolean
  • isToggled(command: string, ...args: any[]): boolean
  • isVisible(command: string, ...args: any[]): boolean
  • onStart(): void
  • Register the given handler for the given command identifier.

    If there is already a handler for the given command then the given handler is registered as more specific, and has higher priority during enablement, visibility and toggle state evaluations.

    Parameters

    Returns Disposable

  • unregisterCommand(command: Command): void
  • unregisterCommand(id: string): void