Class: OnQueryController<D, R>
Defined in: src/wirestate-lit/queries/on-query-controller.ts:30
Reactive controller that registers a query handler.
Remarks
Registers on host connect. Unregisters on disconnect. Re-registers when the nearest container changes.
Example
import { LitElement } from "lit";
import { OnQueryController } from "@wirestate/lit";
class ThemeHost extends LitElement {
private readonly queryTheme = new OnQueryController(this, "CURRENT_THEME", () => "dark");
}Type Parameters
| Type Parameter | Default type |
|---|---|
D | unknown |
R | unknown |
Implements
ReactiveController
Constructors
Constructor
new OnQueryController<D, R>(
host: ReactiveElement,
type: QueryType,
handler: QueryHandler<D, R>): OnQueryController<D, R>;Defined in: src/wirestate-lit/queries/on-query-controller.ts:42
Parameters
| Parameter | Type | Description |
|---|---|---|
host | ReactiveElement | The host element. |
type | QueryType | Unique identifier of the query to handle. |
handler | QueryHandler<D, R> | The query handler function. |
Returns
OnQueryController<D, R>
Methods
hostConnected()
hostConnected(): void;Defined in: src/wirestate-lit/queries/on-query-controller.ts:63
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/queries/on-query-controller.ts:68
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