lit-ui-router-mobx / RouterStore
Class: RouterStore
Defined in: router-store.ts:24
An observable mirror of a router's current state.
A single transitionService.onSuccess hook (registered by attach) pushes the current state, params, and transition into MobX observables. Components observe the store through ReactionController / RouterReactionController selectors and re-render automatically when the values they select change — no manual requestUpdate() calls and no per-component hook subscriptions.
Use the for factory to get the store for a router: it memoizes one store (and one transition hook) per router instance.
Constructors
Constructor
new RouterStore(): RouterStore;Defined in: router-store.ts:53
Returns
RouterStore
Properties
| Property | Type | Default value | Description | Defined in |
|---|---|---|---|---|
current? | StateDeclaration | undefined | The current state declaration (globals.current). | router-store.ts:26 |
params | RawParams | {} | The current parameter values (globals.params), replaced per transition. | router-store.ts:29 |
transition? | Transition | undefined | The most recent successful transition. | router-store.ts:32 |
Methods
attach()
attach(router): () => void;Defined in: router-store.ts:75
Starts mirroring the given router. Called by for; call directly only when managing the store instance yourself, and at most once per store.
Parameters
| Parameter | Type |
|---|---|
router | UIRouter |
Returns
the hook's deregistration function.
() => void
for()
static for(router): RouterStore;Defined in: router-store.ts:43
The observable store for the given router — one per router instance. The first call attaches the store's transition hook; the hook (and the store) live as long as the router itself.
Parameters
| Parameter | Type |
|---|---|
router | UIRouter |
Returns
RouterStore
includes()
includes(stateOrName, params?): boolean;Defined in: router-store.ts:93
Observable version of StateService.includes: is the state (or glob pattern, e.g. 'admin.**') included in the current active state?
Parameters
| Parameter | Type |
|---|---|
stateOrName | StateOrName |
params? | RawParams |
Returns
boolean