@univerjscoreinterfacesIcommandservice

@univerjs/core v0.5.4


Interface: ICommandService

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:185

The service to register and execute commands.

Methods

beforeCommandExecuted()

beforeCommandExecuted(listener): IDisposable

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:235

Register a callback function that will be executed before a command is executed.

Parameters

ParameterType
listenerCommandListener

Returns

IDisposable


executeCommand()

executeCommand<P, R>(
   id, 
   params?, 
options?): Promise<R>

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:213

Execute a command with the given id and parameters.

Type Parameters

Type ParameterDefault type
P extends objectobject
Rboolean

Parameters

ParameterTypeDescription
idstringIdentifier of the command.
params?PParameters of this execution.
options?IExecutionOptionsOptions of this execution.

Returns

Promise<R>

The result of the execution. It is a boolean value by default which indicates the command is executed.


hasCommand()

hasCommand(commandId): boolean

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:195

Check if a command is already registered at the current command service.

Parameters

ParameterTypeDescription
commandIdstringThe id of the command.

Returns

boolean

If the command is registered, return true, otherwise return false.


onCommandExecuted()

onCommandExecuted(listener): IDisposable

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:230

Register a callback function that will be executed after a command is executed.

Parameters

ParameterType
listenerCommandListener

Returns

IDisposable


registerCommand()

registerCommand(command): IDisposable

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:200

Register a command to the command service.

Parameters

ParameterTypeDescription
commandICommand<unknown>The command to register.

Returns

IDisposable


registerMultipleCommand()

registerMultipleCommand(command): IDisposable

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:205

Register a command as a multi command.

Parameters

ParameterTypeDescription
commandICommand<unknown>The command to register as a multi command.

Returns

IDisposable


syncExecuteCommand()

syncExecuteCommand<P, R>(
   id, 
   params?, 
   options?): R

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:225

Execute a command with the given id and parameters synchronously.

Type Parameters

Type ParameterDefault type
P extends objectobject
Rboolean

Parameters

ParameterTypeDescription
idstringIdentifier of the command.
params?PParameters of this execution.
options?IExecutionOptionsOptions of this execution.

Returns

R

The result of the execution. It is a boolean value by default which indicates the command is executed.