ui-router-signals / RouterSignals
Class: RouterSignals
Defined in: ui-router-signals/src/router-signals.ts:33
A signal mirror of a router's current state.
A single transitionService.onSuccess hook (registered by attach) writes one RouteSnapshot per successful transition into a Signal.State. The public fields are read-only Signal.Computeds over it, so any signal consumer — a watchSelection callback, a framework binding such as lit-ui-router-signals, or a @lit-labs/signals SignalWatcher render — tracks exactly the fields it reads. onSuccess is the only hook a later transition cannot supersede, so every value is a settled route.
Use the for factory to get the signals for a router: it memoizes one instance (and one transition hook) per router.
Constructors
Constructor
new RouterSignals(): RouterSignals;Returns
RouterSignals
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
current | readonly | Computed< | StateDeclaration | undefined> | The current state declaration (globals.current). | ui-router-signals/src/router-signals.ts:42 |
params | readonly | Computed<RawParams> | The current parameter values (globals.params), replaced per transition. | ui-router-signals/src/router-signals.ts:46 |
route | readonly | Computed<RouteSnapshot> | The whole route as one value, replaced per transition. | ui-router-signals/src/router-signals.ts:37 |
transition | readonly | Computed< | Transition | undefined> | The most recent successful transition. | ui-router-signals/src/router-signals.ts:51 |
Methods
attach()
attach(router): () => void;Defined in: ui-router-signals/src/router-signals.ts:92
Starts mirroring the given router. Called by for; call directly only when managing the instance yourself.
Idempotent per router: attaching again to the router already being mirrored returns the same deregistration function instead of registering a second hook. Calling that function detaches, after which the instance can be attached again.
Parameters
| Parameter | Type |
|---|---|
router | UIRouter |
Returns
the hook's deregistration function.
() => void
Throws
if already attached to a different router — one instance mirrors one router; use for to get that router's own signals.
for()
static for(router): RouterSignals;Defined in: ui-router-signals/src/router-signals.ts:65
The signals for the given router — one instance per router. The first call attaches the transition hook; the hook (and the instance) live as long as the router itself.
Parameters
| Parameter | Type |
|---|---|
router | UIRouter |
Returns
RouterSignals
includes()
includes(stateOrName, params?): boolean;Defined in: ui-router-signals/src/router-signals.ts:123
Tracked StateService.includes, evaluated against the current route: is the state (or glob pattern, e.g. 'admin.**') included in the settled active state? Reading it inside a computed or watcher subscribes to every transition.
Parameters
| Parameter | Type |
|---|---|
stateOrName | StateOrName |
params? | RawParams |
Returns
boolean