Skip to content

Commit ebdb596

Browse files
authored
fix(router-state): revert router state changes (#2265)
Reverts 699f0a0.
1 parent a4f3a7f commit ebdb596

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ $ npm install @ngxs/store@dev
1515
- Refactor(store): Replace `exhaustMap` [#2254](https://github.com/ngxs/store/pull/2254)
1616
- Refactor(store): Tree-shake development options token [#2260](https://github.com/ngxs/store/pull/2260)
1717
- Performance(store): Prevent initializing state factory at feature levels [#2261](https://github.com/ngxs/store/pull/2261)
18+
- Revert: Revert router state changes [#2264](https://github.com/ngxs/store/pull/2264)
1819

1920
### 18.1.5 2024-11-12
2021

2122
- Fix(store): Prevent writing to state once action handler is unsubscribed [#2231](https://github.com/ngxs/store/pull/2231)
2223
- Performance(store): Replace `instanceof Function` with `typeof` [#2247](https://github.com/ngxs/store/pull/2247)
2324
- Refactor(store): Use `Object.is` as default equality check [#2245](https://github.com/ngxs/store/pull/2245)
2425
- Refactor(store): Tree-shake internal state tokens [#2246](https://github.com/ngxs/store/pull/2246)
25-
- Refactor(router-plugin): Mark selectors as pure [#2248](https://github.com/ngxs/store/pull/2248)
26+
- Refactor(router-plugin): Mark selectors as pure [#2248](https://github.com/ngxs/store/pull/2248) **(Note: reverted in 18.1.6)**
2627
- Refactor(storage-plugin): Mark engine tokens as pure [#2249](https://github.com/ngxs/store/pull/2249)
2728

2829
### 18.1.4 2024-10-23

packages/router-plugin/src/router.state.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
NavigationEnd,
1111
Event
1212
} from '@angular/router';
13-
import { Action, createSelector, State, StateContext, StateToken, Store } from '@ngxs/store';
13+
import { Action, Selector, State, StateContext, StateToken, Store } from '@ngxs/store';
1414
import {
1515
NavigationActionTiming,
1616
ɵNGXS_ROUTER_PLUGIN_OPTIONS
@@ -86,19 +86,17 @@ export class RouterState implements OnDestroy {
8686

8787
private _destroy$ = new ReplaySubject<void>(1);
8888

89-
static state = /* @__PURE__ */ createSelector(
90-
[ROUTER_STATE_TOKEN],
91-
(state: RouterStateModel<RouterStateSnapshot>) => {
92-
// The `state` is optional if the selector is invoked before the router
93-
// state is registered in NGXS.
94-
return state?.state;
95-
}
96-
);
89+
@Selector()
90+
static state<T = RouterStateSnapshot>(state: RouterStateModel<T>) {
91+
// The `state` is optional if the selector is invoked before the router
92+
// state is registered in NGXS.
93+
return state?.state;
94+
}
9795

98-
static url = /* @__PURE__ */ createSelector(
99-
[ROUTER_STATE_TOKEN],
100-
state => state?.state?.url
101-
);
96+
@Selector()
97+
static url(state: RouterStateModel): string | undefined {
98+
return state?.state?.url;
99+
}
102100

103101
constructor() {
104102
this._setUpStoreListener();

0 commit comments

Comments
 (0)