Skip to content

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

typescript
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 ParameterDefault type
Dunknown
Runknown

Implements

  • ReactiveController

Constructors

Constructor

ts
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

ParameterTypeDescription
hostReactiveElementThe host element.
typeQueryTypeUnique identifier of the query to handle.
handlerQueryHandler<D, R>The query handler function.

Returns

OnQueryController<D, R>

Methods

hostConnected()

ts
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

ts
ReactiveController.hostConnected

hostDisconnected()

ts
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

ts
ReactiveController.hostDisconnected