Skip to content

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 ​

ts
new RouterSignals(): RouterSignals;

Returns ​

RouterSignals

Properties ​

PropertyModifierTypeDescriptionDefined in
currentreadonlyComputed< | StateDeclaration | undefined>The current state declaration (globals.current).ui-router-signals/src/router-signals.ts:42
paramsreadonlyComputed<RawParams>The current parameter values (globals.params), replaced per transition.ui-router-signals/src/router-signals.ts:46
routereadonlyComputed<RouteSnapshot>The whole route as one value, replaced per transition.ui-router-signals/src/router-signals.ts:37
transitionreadonlyComputed< | Transition | undefined>The most recent successful transition.ui-router-signals/src/router-signals.ts:51

Methods ​

attach() ​

ts
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 ​

ParameterType
routerUIRouter

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() ​

ts
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 ​

ParameterType
routerUIRouter

Returns ​

RouterSignals


includes() ​

ts
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 ​

ParameterType
stateOrNameStateOrName
params?RawParams

Returns ​

boolean