Skip to content

Commit

Permalink
chore(docs): Add docs on usage of custom router state serializer with…
Browse files Browse the repository at this point in the history
… store freeze (#426)
  • Loading branch information
zakhenry authored and brandonroberts committed Sep 25, 2017
1 parent 5573ec0 commit 358f5ce
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/router-store/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
## Custom Router State Serializer

During each navigation cycle, a `RouterNavigationAction` is dispatched with a snapshot of the state in its payload, the `RouterStateSnapshot`. The `RouterStateSnapshot` is a large complex structure, containing many pieces of information about the current state and what's rendered by the router. This can cause performance
issues when used with the Store Devtools. In most cases, you may only need a piece of information from the `RouterStateSnapshot`. In order to pair down the `RouterStateSnapshot` provided during navigation, you provide a custom serializer for the snapshot to only return what you need to be added to the payload and store.
issues when used with the Store Devtools. In most cases, you may only need a piece of information from the `RouterStateSnapshot`. In order to pare down the `RouterStateSnapshot` provided during navigation, you provide a custom serializer for the snapshot to only return what you need to be added to the payload and store.

Additionally, the router state snapshot is a mutable object, which can cause issues when developing with [store freeze](https://github.com/brandonroberts/ngrx-store-freeze) to prevent direct state mutations. This can be avoided by using a custom serializer.

To use the time-traveling debugging in the Devtools, you must return an object containing the `url` when using the `routerReducer`.

Expand Down Expand Up @@ -54,4 +56,4 @@ export const reducers: ActionReducerMap<State> = {
]
})
export class AppModule { }
```
```

0 comments on commit 358f5ce

Please sign in to comment.