Skip to content

lit-ui-router-mobx / RouterStore

Class: RouterStore ​

Defined in: ui-router-mobx/dist/router-store.d.ts:15

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. Any MobX reaction, autorun or computed that reads the store re-runs when the values it reads change, with no per-consumer transition hooks.

Use the for factory to get the store for a router: it memoizes one store (and one transition hook) per router instance.

Constructors ​

Constructor ​

ts
new RouterStore(): RouterStore;

Defined in: ui-router-mobx/dist/router-store.d.ts:31

Returns ​

RouterStore

Properties ​

PropertyTypeDescriptionDefined in
current?StateDeclarationThe current state declaration (globals.current).ui-router-mobx/dist/router-store.d.ts:17
paramsRawParamsThe current parameter values (globals.params), replaced per transition.ui-router-mobx/dist/router-store.d.ts:19
transition?TransitionThe most recent successful transition.ui-router-mobx/dist/router-store.d.ts:21

Methods ​

attach() ​

ts
attach(router): () => void;

Defined in: ui-router-mobx/dist/router-store.d.ts:47

Starts mirroring the given router. Called by for; call directly only when managing the store 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 the store, after which it can be attached again.

Parameters ​

ParameterType
routerUIRouter

Returns ​

the hook's deregistration function.

() => void

Throws ​

if the store is already attached to a different router — one store mirrors one router; use for to get that router's own store.


for() ​

ts
static for(router): RouterStore;

Defined in: ui-router-mobx/dist/router-store.d.ts:30

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 ​

ParameterType
routerUIRouter

Returns ​

RouterStore


includes() ​

ts
includes(stateOrName, params?): boolean;

Defined in: ui-router-mobx/dist/router-store.d.ts:53

Observable version of StateService.includes: is the state (or glob pattern, e.g. 'admin.**') included in the current active state?

Parameters ​

ParameterType
stateOrNameStateOrName
params?RawParams

Returns ​

boolean