Function: onCommand()
ts
function onCommand<D, R>(type: CommandType): OnCommandDecorator<D, R>;Defined in: src/wirestate-lit/commands/on-command.ts:47
Decorator for Lit element methods that handle a specific command.
Type Parameters
| Type Parameter | Default type |
|---|---|
D | unknown |
R | unknown |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | CommandType | Unique identifier of the command to handle. |
Returns
OnCommandDecorator<D, R>
A method decorator function.
Remarks
The handler is registered when the host connects and unregistered when it disconnects.
Example
typescript
class MyElement extends LitElement {
@onCommand("SAVE")
private onSave(data: SomeData): void {
// handle command
}
}