Skip to content

Function: onQuery()

ts
function onQuery<D, R>(type: QueryType): OnQueryDecorator<D, R>;

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

Decorator for Lit element methods that handle a specific query.

Type Parameters

Type ParameterDefault type
Dunknown
Runknown

Parameters

ParameterTypeDescription
typeQueryTypeUnique identifier of the query to handle.

Returns

OnQueryDecorator<D, R>

A method decorator function.

Remarks

The handler is registered when the host connects and unregistered when it disconnects.

Example

typescript
class MyElement extends LitElement {
  @onQuery("GET_USER_NAME")
  private onGetUserName(data: QueryData) {
    return "Alice";
  }
}