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.
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
RefController<readonly [SubscriptionRef.SubscriptionRef<RouteSnapshot>],T>
Type Parameters
| Type Parameter |
|---|
T |
Constructors
Constructor
new RouterRefController<T>(
host,
selector,
options?
): RouterRefController<T>;Defined in: lit-ui-router-effect/src/router-ref-controller.ts:66
Parameters
| Parameter | Type |
|---|---|
host | ReactiveControllerHost & Element |
selector | (route) => T |
options | RouterRefControllerOptions<T> |
Returns
RouterRefController<T>
Overrides
Properties
| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
value | T | The selected value, for use in render(). | RefController.value | lit-ui-router-effect/src/ref-controller.ts:119 |
Methods
hostConnected()
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
hostDisconnected()
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()
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
| Parameter | Type |
|---|---|
refs | RefSource<readonly [SubscriptionRef<RouteSnapshot>]> |
Returns
void
Inherited from
setRouter()
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
| Parameter | Type |
|---|---|
router | UIRouter |
Returns
void