lit-ui-router-mobx / ReactionController
Class: ReactionController<T>
Defined in: reaction-controller.ts:39
A ReactiveController that composes MobX with the Lit lifecycle: it runs a MobX reaction over an explicit selector while the host is connected and calls host.requestUpdate() when the selected value changes.
This is a selector-based alternative to render auto-tracking mixins such as MobxLitElement:
- No base class required — works on any LitElement (or other host).
- Dependencies are explicit: the selector names exactly which observables drive the host, and
equals: comparer.structuralgives precise, value-based change detection. - Lifecycle is automatic: the reaction is created in
hostConnectedand disposed inhostDisconnected— no manual disposer bookkeeping. - The reaction fires immediately on (re)connect, so hosts that re-enter the DOM (e.g. sticky routed components) synchronize with the current store state instead of rendering stale values.
The selected value is exposed as .value for use in render().
Type Parameters
| Type Parameter |
|---|
T |
Implements
Constructors
Constructor
new ReactionController<T>(
host,
expression,
options?): ReactionController<T>;Defined in: reaction-controller.ts:44
Parameters
| Parameter | Type |
|---|---|
host | ReactiveControllerHost |
expression | () => T |
options | ReactionControllerOptions<T> |
Returns
ReactionController<T>
Properties
| Property | Type | Defined in |
|---|---|---|
value | T | reaction-controller.ts:40 |
Methods
hostConnected()
hostConnected(): void;Defined in: reaction-controller.ts:52
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.hostConnected;hostDisconnected()
hostDisconnected(): void;Defined in: reaction-controller.ts:64
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;