Class: OnCommandController<D, R>
Defined in: src/wirestate-lit/commands/on-command-controller.ts:32
Reactive controller that registers a command handler.
Remarks
Registers on host connect. Unregisters on disconnect. Re-registers when the nearest container changes.
Example
import { LitElement } from "lit";
import { OnCommandController } from "@wirestate/lit";
class SaveButton extends LitElement {
private readonly saveCommand = new OnCommandController(this, "SAVE", (data: FormData) => {
console.log("save", data);
});
}Type Parameters
| Type Parameter | Default type |
|---|---|
D | unknown |
R | unknown |
Implements
ReactiveController
Constructors
Constructor
new OnCommandController<D, R>(
host: ReactiveElement,
type: CommandType,
handler: CommandHandler<D, R>): OnCommandController<D, R>;Defined in: src/wirestate-lit/commands/on-command-controller.ts:44
Parameters
| Parameter | Type | Description |
|---|---|---|
host | ReactiveElement | The host element. |
type | CommandType | Unique identifier of the command to handle. |
handler | CommandHandler<D, R> | The command handler function. |
Returns
OnCommandController<D, R>
Methods
hostConnected()
hostConnected(): void;Defined in: src/wirestate-lit/commands/on-command-controller.ts:65
Called when the host is connected to the component tree. For custom element hosts, this corresponds to the connectedCallback() lifecycle, which is only called when the component is connected to the document.
Returns
void
Implementation of
ReactiveController.hostConnectedhostDisconnected()
hostDisconnected(): void;Defined in: src/wirestate-lit/commands/on-command-controller.ts:70
Called when the host is disconnected from the component tree. For custom element hosts, this corresponds to the disconnectedCallback() lifecycle, which is called the host or an ancestor component is disconnected from the document.
Returns
void
Implementation of
ReactiveController.hostDisconnected