@univerjscoreclassesCommandservice

@univerjs/core v0.5.4


Class: CommandService

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

The service to register and execute commands.

Extends

Implements

Constructors

new CommandService()

new CommandService(_injector, _logService): CommandService

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

Parameters

ParameterType
_injectorInjector
_logServiceILogService

Returns

CommandService

Overrides

Disposable.constructor

Properties

PropertyModifierTypeDefault valueInherited fromDefined in
_commandRegistryreadonlyCommandRegistryundefined-packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:282
_disposedprotectedbooleanfalseDisposable._disposedpackages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:96

Methods

beforeCommandExecuted()

beforeCommandExecuted(listener): IDisposable

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

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

Parameters

ParameterType
listenerCommandListener

Returns

IDisposable

Implementation of

ICommandService.beforeCommandExecuted


dispose()

dispose(): void

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

Returns

void

Overrides

Disposable.dispose


disposeWithMe()

disposeWithMe(disposable): IDisposable

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:99

Parameters

ParameterType
disposableDisposableLike

Returns

IDisposable

Inherited from

Disposable.disposeWithMe


ensureNotDisposed()

protected ensureNotDisposed(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:103

Returns

void

Inherited from

Disposable.ensureNotDisposed


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:348

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.

Implementation of

ICommandService.executeCommand


hasCommand()

hasCommand(commandId): boolean

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

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.

Implementation of

ICommandService.hasCommand


onCommandExecuted()

onCommandExecuted(listener): IDisposable

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

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

Parameters

ParameterType
listener(commandInfo) => void

Returns

IDisposable

Implementation of

ICommandService.onCommandExecuted


registerCommand()

registerCommand(command): IDisposable

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

Register a command to the command service.

Parameters

ParameterTypeDescription
commandICommandThe command to register.

Returns

IDisposable

Implementation of

ICommandService.registerCommand


registerMultipleCommand()

registerMultipleCommand(command): IDisposable

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

Register a command as a multi command.

Parameters

ParameterTypeDescription
commandICommandThe command to register as a multi command.

Returns

IDisposable

Implementation of

ICommandService.registerMultipleCommand


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:385

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.

Implementation of

ICommandService.syncExecuteCommand