-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(RouterStore): Add generic type to RouterReducerState (#292)
Closes #289
- Loading branch information
1 parent
bf7f70c
commit 6da3ec5
Showing
5 changed files
with
54 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
import { RouterStateSerializer } from '@ngrx/router-store'; | ||
import { RouterStateSnapshot } from '@angular/router'; | ||
import { RouterStateSnapshot, Params } from '@angular/router'; | ||
|
||
/** | ||
* The RouterStateSerializer takes the current RouterStateSnapshot | ||
* and returns any pertinent information needed. The snapshot contains | ||
* all information about the state of the router at the given point in time. | ||
* The entire snapshot is complex and not always needed. In this case, you only | ||
* need the URL from the snapshot in the store. Other items could be | ||
* returned such as route parameters, query parameters and static route data. | ||
* need the URL and query parameters from the snapshot in the store. Other items could be | ||
* returned such as route parameters and static route data. | ||
*/ | ||
|
||
export interface RouterStateUrl { | ||
url: string; | ||
queryParams: Params; | ||
} | ||
|
||
export class CustomRouterStateSerializer | ||
implements RouterStateSerializer<RouterStateUrl> { | ||
serialize(routerState: RouterStateSnapshot): RouterStateUrl { | ||
const { url } = routerState; | ||
const queryParams = routerState.root.queryParams; | ||
|
||
return { url }; | ||
return { url, queryParams }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters