Skip to main content

Function: registerCommand()

registerCommand(command, callback, thisArg?): Disposable

Define a command, to be executed later, either by calling commands.executeCommand or by referencing its name in the command field of a StatusBarItem.

For examples, see commands and window.createStatusBarItem.

Parameters

command

string

the name of the command. The name must be unique over all extensions. It is recommended to prefix this name with the name of the extension, to avoid conflicts with commands from other extensions.

callback

(...args) => any

the command to execute

thisArg?

any

The value of this provided for the call to callback

Returns

Disposable

A disposable that unregisters this command when being disposed

Throws

if a command with the same name is already registered.

Defined in

packages/extension-api/src/extension-api.d.ts:739