lit-ui-router-effect / RefController
Class: RefController<Refs, T>
Defined in: ref-controller.ts:100
A ReactiveController that composes Effect's SubscriptionRef with the Lit lifecycle: it selects over one or more refs and calls host.requestUpdate() when the selected value changes.
The subscription is a single fiber — Stream.runForEach over the refs' changes — forked in hostConnected and interrupted in hostDisconnected, so it lives exactly as long as the host is in the document. changes replays the current value, and the controller also seeds .value synchronously on connect, so a reconnected host (a sticky routed component) renders current state, never stale state.
Refs given directly are read once more at construction, so .value is live before the host ever connects — a host rendered on the server sees the same value a browser would. Refs resolved on connect carry options.initialValue until then.
The selected value is exposed as .value for use in render().
Extended by
Type Parameters
| Type Parameter |
|---|
Refs extends SubscriptionRefs |
T |
Implements
Constructors
Constructor
new RefController<Refs, T>(
host,
refs,
selector,
options?
): RefController<Refs, T>;Defined in: ref-controller.ts:111
Parameters
| Parameter | Type |
|---|---|
host | ReactiveControllerHost |
refs | RefSource<Refs> |
selector | (...values) => T |
options | RefControllerOptions<T> |
Returns
RefController<Refs, T>
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
value | T | The selected value, for use in render(). | ref-controller.ts:105 |
Methods
hostConnected()
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
Implementation of
ReactiveController.hostConnectedhostDisconnected()
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
Implementation of
ReactiveController.hostDisconnected