Skip to content

lit-ui-router-effect / RouterRefController

Class: RouterRefController<T> ​

Defined in: lit-ui-router-effect/src/router-ref-controller.ts:58

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 or scoped router) warns once in development and is a no-op until it reconnects under one or is handed a router with RouterRefController.setRouter; .value stays at options.initialValue.

Extends ​

Type Parameters ​

Type Parameter
T

Constructors ​

Constructor ​

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

Defined in: lit-ui-router-effect/src/router-ref-controller.ts:66

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.valuelit-ui-router-effect/src/ref-controller.ts:119

Methods ​

hostConnected() ​

ts
hostConnected(): void;

Defined in: lit-ui-router-effect/src/router-ref-controller.ts:125

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

Overrides ​

RefController.hostConnected


hostDisconnected() ​

ts
hostDisconnected(): void;

Defined in: lit-ui-router-effect/src/router-ref-controller.ts:133

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

Overrides ​

RefController.hostDisconnected


setRefs() ​

ts
protected setRefs(refs): void;

Defined in: lit-ui-router-effect/src/ref-controller.ts:155

Replaces the refs. A connected controller interrupts its fiber and re-seeds and re-forks on the new refs, as a reconnect does; a disconnected one only records them for its next hostConnected.

Parameters ​

ParameterType
refsRefSource<readonly [SubscriptionRef<RouteSnapshot>]>

Returns ​

void

Inherited from ​

RefController.setRefs


setRouter() ​

ts
setRouter(router): void;

Defined in: lit-ui-router-effect/src/router-ref-controller.ts:118

Follows router from now on. A connected host interrupts its fiber, re-seeds .value from the new router's routeRef, re-forks, and updates; a disconnected one takes the router on its next hostConnected. The router already followed is a no-op.

Parameters ​

ParameterType
routerUIRouter

Returns ​

void