Skip to content

Commit

Permalink
fix(router-state): revert router state changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arturovt committed Nov 20, 2024
1 parent a4f3a7f commit 96f0a10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ $ 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

- Fix(store): Prevent writing to state once action handler is unsubscribed [#2231](https://github.com/ngxs/store/pull/2231)
- 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
Expand Down
24 changes: 11 additions & 13 deletions packages/router-plugin/src/router.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -86,19 +86,17 @@ export class RouterState implements OnDestroy {

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

static state = /* @__PURE__ */ createSelector(
[ROUTER_STATE_TOKEN],
(state: RouterStateModel<RouterStateSnapshot>) => {
// The `state` is optional if the selector is invoked before the router
// state is registered in NGXS.
return state?.state;
}
);
@Selector()
static state<T = RouterStateSnapshot>(state: RouterStateModel<T>) {
// 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();
Expand Down

0 comments on commit 96f0a10

Please sign in to comment.