Skip to content

Class: OnQueryController<R, P, T> ​

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 context changes.

Example ​

typescript
import { LitElement } from "lit";
import { OnQueryController } from "@wirestate/lit";

class CheckoutHost extends LitElement {
  private readonly querySummary = new OnQueryController(this, "CHECKOUT_SUMMARY", () => ({
    itemCount: 2,
    total: 48,
  }));
}

Type Parameters ​

Type ParameterDefault type
Runknown
Punknown
T extends QueryTypeQueryType

Implements ​

  • ReactiveController

Constructors ​

Constructor ​

ts
new OnQueryController<R, P, T>(
   host: ReactiveElement, 
   type: T, 
handler: QueryHandler<R, P, T>): OnQueryController<R, P, T>;

Defined in: src/wirestate-lit/queries/on-query-controller.ts:46

Parameters ​

ParameterTypeDescription
hostReactiveElementThe host element.
typeTQuery type to handle.
handlerQueryHandler<R, P, T>The query handler function.

Returns ​

OnQueryController<R, P, T>

Methods ​

hostConnected() ​

ts
hostConnected(): void;

Defined in: src/wirestate-lit/queries/on-query-controller.ts:66

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: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 ​

ts
ReactiveController.hostDisconnected