API Reference
@univerjs
@univerjs/core
interfaces
Imulticommand

@univerjs/core v0.4.2Docs


Interface: IMultiCommand<P, R>

A command that may have multiple implementations. Each implementation should have different priority and preconditions callback to determine which implementation should be executed.

Extends

Type Parameters

Type ParameterDefault type
P extends objectobject
Rboolean

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
idreadonlystringIdentifier 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' }ICommand.idsubmodules/univer/packages/core/src/services/command/command.service.ts:66 (opens in a new tab)
namepublicstringThe name of the multi command. It should be unique in the application.-submodules/univer/packages/core/src/services/command/command.service.ts:88 (opens in a new tab)
preconditions?public(contextService: IContextService) => booleanA callback function that tells ICommandService if this implementation should be executed.-submodules/univer/packages/core/src/services/command/command.service.ts:98 (opens in a new tab)
prioritypublicnumberPriority of this implementation. Implementation with higher priority will be checked first.-submodules/univer/packages/core/src/services/command/command.service.ts:92 (opens in a new tab)
typereadonlyCommandTypeThe type of the command.ICommand.typesubmodules/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

ParameterTypeDescription
accessorIAccessorThe accessor to the dependency injection container.
params?PParams of the command. Params should be serializable.
options?IExecutionOptionsOptions 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.

Inherited from

ICommand.handler

Defined in

submodules/univer/packages/core/src/services/command/command.service.ts:79 (opens in a new tab)


Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.