Skip to content

lit-ui-router-effect / RouterRefController

Class: RouterRefController<T>

Defined in: router-ref-controller.ts:46

A RefController preselected on the router: follows the routeRef of the host's <ui-router> context.

ts
class App extends LitElement {
  private active = new RouterRefController(
    this,
    (route) => route.includes('admin.**'),
  );

  render() {
    return html`...${this.active.value ? 'admin' : ''}...`;
  }
}

Same lifecycle as the base: seeded synchronously on every (re)connect, one forked fiber while connected, interrupted on disconnect. A host outside any <ui-router> (with no explicit router option) warns once in development and is a no-op until it reconnects under one; .value stays at options.initialValue.

Extends

Type Parameters

Type Parameter
T

Constructors

Constructor

ts
new RouterRefController<T>(
   host, 
   selector, 
   options?
): RouterRefController<T>;

Defined in: router-ref-controller.ts:50

Parameters

ParameterType
hostReactiveControllerHost & Element
selector(route) => T
optionsRouterRefControllerOptions<T>

Returns

RouterRefController<T>

Overrides

RefController.constructor

Properties

PropertyTypeDescriptionInherited fromDefined in
valueTThe selected value, for use in render().RefController.valueref-controller.ts:105

Methods

hostConnected()

ts
hostConnected(): void;

Defined in: ref-controller.ts:127

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

Inherited from

RefController.hostConnected


hostDisconnected()

ts
hostDisconnected(): void;

Defined in: ref-controller.ts:140

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

Inherited from

RefController.hostDisconnected