diff --git a/CHANGELOG.md b/CHANGELOG.md index ed45f5c47..2bd846b78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ $ npm install @ngxs/store@dev - Refactor(store): Replace `exhaustMap` [#2254](https://github.com/ngxs/store/pull/2254) - Refactor(store): Tree-shake development options token [#2260](https://github.com/ngxs/store/pull/2260) - Performance(store): Prevent initializing state factory at feature levels [#2261](https://github.com/ngxs/store/pull/2261) +- Revert: Revert router state changes [#2264](https://github.com/ngxs/store/pull/2264) ### 18.1.5 2024-11-12 @@ -22,7 +23,7 @@ $ npm install @ngxs/store@dev - Performance(store): Replace `instanceof Function` with `typeof` [#2247](https://github.com/ngxs/store/pull/2247) - Refactor(store): Use `Object.is` as default equality check [#2245](https://github.com/ngxs/store/pull/2245) - Refactor(store): Tree-shake internal state tokens [#2246](https://github.com/ngxs/store/pull/2246) -- Refactor(router-plugin): Mark selectors as pure [#2248](https://github.com/ngxs/store/pull/2248) +- Refactor(router-plugin): Mark selectors as pure [#2248](https://github.com/ngxs/store/pull/2248) **(Note: reverted in 18.1.6)** - Refactor(storage-plugin): Mark engine tokens as pure [#2249](https://github.com/ngxs/store/pull/2249) ### 18.1.4 2024-10-23 diff --git a/packages/router-plugin/src/router.state.ts b/packages/router-plugin/src/router.state.ts index 308116c57..9703e60fd 100644 --- a/packages/router-plugin/src/router.state.ts +++ b/packages/router-plugin/src/router.state.ts @@ -10,7 +10,7 @@ import { NavigationEnd, Event } from '@angular/router'; -import { Action, createSelector, State, StateContext, StateToken, Store } from '@ngxs/store'; +import { Action, Selector, State, StateContext, StateToken, Store } from '@ngxs/store'; import { NavigationActionTiming, ɵNGXS_ROUTER_PLUGIN_OPTIONS @@ -86,19 +86,17 @@ export class RouterState implements OnDestroy { private _destroy$ = new ReplaySubject(1); - static state = /* @__PURE__ */ createSelector( - [ROUTER_STATE_TOKEN], - (state: RouterStateModel) => { - // The `state` is optional if the selector is invoked before the router - // state is registered in NGXS. - return state?.state; - } - ); + @Selector() + static state(state: RouterStateModel) { + // The `state` is optional if the selector is invoked before the router + // state is registered in NGXS. + return state?.state; + } - static url = /* @__PURE__ */ createSelector( - [ROUTER_STATE_TOKEN], - state => state?.state?.url - ); + @Selector() + static url(state: RouterStateModel): string | undefined { + return state?.state?.url; + } constructor() { this._setUpStoreListener();