Skip to content

lit-ui-router / requestRouter

Variable: requestRouter ​

ts
const requestRouter: (target, options?) => UIRouterLit | undefined;

Defined in: packages/lit-ui-router/src/context.ts:316

Requests the router from whichever provider answers on target, and returns the value a provider supplied synchronously — the router instance of requestContext.

The target is any EventTarget, not only an element. Returns undefined when nobody answered.

Parameters ​

ParameterTypeDescription
targetEventTargetthe event target to dispatch the request from
options?RequestRouterOptionssubscription and callback options

Returns ​

UIRouterLit | undefined

Example ​

ts
import { requestRouter } from 'lit-ui-router/context';

class MyElement extends LitElement {
  connectedCallback() {
    super.connectedCallback();
    this.router = requestRouter(this);
  }
}