Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
fix ngrx/router-store Chrome Redux DevTools Extension crashing issue.…
Browse files Browse the repository at this point in the history
…fix ngrx/router-store Chrome Redux DevTools Extension crashing

Ref: ngrx/platform#537
  • Loading branch information
joseluisq committed Mar 7, 2019
1 parent fc82678 commit a29836d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 27 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ But there are only three differences at properties level:

Since it's based on `ActivatedRouteSnapshot`, you can also access to their properties as usual with the exception that `url` was moved to `urlSegments` and `url` is now current string url.

More details about available properties at [router-state.ts](./src/router-state.ts) file.

### Operators

[RxJS](https://angular.io/guide/rx-library) operators:
Expand Down
20 changes: 3 additions & 17 deletions src/router-state.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Type } from '@angular/core'
import { ActivatedRouteSnapshot, Data, ParamMap, Params, Route, UrlSegment } from '@angular/router'
import { Data, Params, UrlSegment } from '@angular/router'
import { RouterNavigationPayload } from '@ngrx/router-store'

/** RouterStateSegments intersection type (token segments mapping object) */
export type RouterStateTokenSegments<T> = T & { [key: string]: string }

/**
* Router activated snapshot state extended of `@angular/router/ActivatedRouteSnapshot`
* Router activated snapshot state based on `@angular/router/ActivatedRouteSnapshot`
*
* - ActivatedRouteSnapshot: https://angular.io/api/router/ActivatedRouteSnapshot#description
* - ActivatedRouteSnapshot source: https://github.com/angular/angular/blob/master/packages/router/src/router_state.ts
Expand All @@ -30,23 +30,9 @@ export interface RouterStatePlusActivatedSnapshot<RouterTokenSegments> {
outlet: string
/** The component of the route */
component: Type<any> | string | null
/** The configuration used to match this route */
readonly routeConfig: Route | null
/** The root of the router state */
readonly root: ActivatedRouteSnapshot
/** The parent of this route in the router state tree */
readonly parent: ActivatedRouteSnapshot | null
/** The first child of this route in the router state tree */
readonly firstChild: ActivatedRouteSnapshot | null
/** The children of this route in the router state tree */
readonly children: ActivatedRouteSnapshot[]
/** The path from the root of the router state tree to this route */
readonly pathFromRoot: ActivatedRouteSnapshot[]
readonly paramMap: ParamMap
readonly queryParamMap: ParamMap
toString (): string
}

/** The router navigation payload extended of NgRx RouterNavigationPayload */
export interface RouterNavPayload<RouterTokenSegments = {}>
extends RouterNavigationPayload<RouterStatePlusActivatedSnapshot<RouterTokenSegments>> {
}
12 changes: 2 additions & 10 deletions src/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class RouterStateSerializerPlus<RouterTokenSegments> implements
): RouterStatePlusActivatedSnapshot<RouterTokenSegments> {
let route = routerState.root

if (route.firstChild) {
while (route.firstChild) {
route = route.firstChild
}

Expand All @@ -49,15 +49,7 @@ export class RouterStateSerializerPlus<RouterTokenSegments> implements
fragment: route.fragment,
data: route.data,
outlet: route.outlet,
component: route.component,
routeConfig: route.routeConfig,
root: route.root,
parent: route.parent,
firstChild: route.firstChild,
children: route.children,
pathFromRoot: route.pathFromRoot,
paramMap: route.paramMap,
queryParamMap: route.queryParamMap
component: route.component
}
}

Expand Down

0 comments on commit a29836d

Please sign in to comment.