@univerjs/core v0.5.0-beta.1 • Docs
Class: CommandService
The service to register and execute commands.
Extends
Implements
Constructors
new CommandService()
new CommandService(_injector, _logService): CommandService
Parameters
Parameter | Type |
---|---|
_injector | Injector |
_logService | ILogService |
Returns
Overrides
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:293
Properties
Property | Modifier | Type | Default value | Inherited from | Defined in |
---|---|---|---|---|---|
_commandRegistry | readonly | CommandRegistry | undefined | - | packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:282 |
_disposed | protected | boolean | false | Disposable ._disposed | packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:93 |
Methods
beforeCommandExecuted()
beforeCommandExecuted(listener): IDisposable
Register a callback function that will be executed before a command is executed.
Parameters
Parameter | Type |
---|---|
listener | CommandListener |
Returns
Implementation of
ICommandService
.beforeCommandExecuted
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:322
dispose()
dispose(): void
Returns
void
Overrides
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:303
disposeWithMe()
disposeWithMe(disposable): IDisposable
Parameters
Parameter | Type |
---|---|
disposable | DisposableLike |
Returns
Inherited from
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:96
ensureNotDisposed()
protected ensureNotDisposed(): void
Returns
void
Inherited from
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:100
executeCommand()
executeCommand<P, R>(
id,
params?,
options?): Promise<R>
Execute a command with the given id and parameters.
Type Parameters
Type Parameter | Default type |
---|---|
P extends object | object |
R | boolean |
Parameters
Parameter | Type | Description |
---|---|---|
id | string | Identifier of the command. |
params ? | P | Parameters of this execution. |
options ? | IExecutionOptions | Options 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
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:348
hasCommand()
hasCommand(commandId): boolean
Check if a command is already registered at the current command service.
Parameters
Parameter | Type | Description |
---|---|---|
commandId | string | The id of the command. |
Returns
boolean
If the command is registered, return true
, otherwise return false
.
Implementation of
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:310
onCommandExecuted()
onCommandExecuted(listener): IDisposable
Register a callback function that will be executed after a command is executed.
Parameters
Parameter | Type |
---|---|
listener | (commandInfo ) => void |
Returns
Implementation of
ICommandService
.onCommandExecuted
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:335
registerCommand()
registerCommand(command): IDisposable
Register a command to the command service.
Parameters
Parameter | Type | Description |
---|---|---|
command | ICommand <object , boolean > | The command to register. |
Returns
Implementation of
ICommandService
.registerCommand
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:314
registerMultipleCommand()
registerMultipleCommand(command): IDisposable
Register a command as a multi command.
Parameters
Parameter | Type | Description |
---|---|---|
command | ICommand <object , boolean > | The command to register as a multi command. |
Returns
Implementation of
ICommandService
.registerMultipleCommand
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:318
syncExecuteCommand()
syncExecuteCommand<P, R>(
id,
params?,
options?): R
Execute a command with the given id and parameters synchronously.
Type Parameters
Type Parameter | Default type |
---|---|
P extends object | object |
R | boolean |
Parameters
Parameter | Type | Description |
---|---|---|
id | string | Identifier of the command. |
params ? | P | Parameters of this execution. |
options ? | IExecutionOptions | Options 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
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/command/command.service.ts:385