@univerjs/core v0.4.2 • Docs
Interface: ICommand<P, R>
In Univer, all data modifications need to be executed through commands. The command-based approach can better track changes in values, implement functions such as undo, redo, and collaborative editing, handle complex associated logic between functions, etc.
All commands should implements this interface or related IMutation or IOperation interface, and should be registered in the ICommandService.
Extended by
Type Parameters
Type Parameter | Default type |
---|---|
P extends object | object |
R | boolean |
Properties
Property | Modifier | Type | Description | Defined in |
---|---|---|---|---|
id | readonly | string | Identifier of the command. It should be unique in the application unless it is a IMultiCommand. Its pattern should be like <namespace>.<type>.<command-name> . Example { id: 'sheet.command.set-selection-frozen' } | submodules/univer/packages/core/src/services/command/command.service.ts:66 (opens in a new tab) |
type | readonly | CommandType | The type of the command. | submodules/univer/packages/core/src/services/command/command.service.ts:70 (opens in a new tab) |
Methods
handler()
handler(
accessor,
params?,
options?): R | Promise<R>
The handler of the command.
Parameters
Parameter | Type | Description |
---|---|---|
accessor | IAccessor | The accessor to the dependency injection container. |
params ? | P | Params of the command. Params should be serializable. |
options ? | IExecutionOptions | Options of the command. |
Returns
R
| Promise
<R
>
The result of the command. By default it should be a boolean value which indicates the command is executed successfully or not.
Defined in
submodules/univer/packages/core/src/services/command/command.service.ts:79 (opens in a new tab)