Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(router-state): revert router state changes #2265

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading