Function: onCommand()
ts
function onCommand<R, P, T>(type: T): OnCommandDecorator<R, P, T>;Defined in: src/wirestate-lit/commands/on-command.ts:53
Decorator for Lit element methods that handle a specific command.
Type Parameters
| Type Parameter | Default type |
|---|---|
R | unknown |
P | unknown |
T extends CommandType | CommandType |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | T | Command type to handle. |
Returns
OnCommandDecorator<R, P, T>
A method decorator function.
Remarks
The handler is registered when the host connects, unregistered when it disconnects, and re-registered when the nearest container context changes. Command handlers are stack-based on the active command bus.
Example
typescript
class MyElement extends LitElement {
@onCommand("SAVE")
private onSave(payload: SomeData): void {
// handle command
}
}