How to extend logic of the With Angular 8, ngrx 8 I keep a router state using custom serializer
export class CustomSerializer implements RouterStateSerializer<RouterStateUrl>
Where the custom state
export interface RouterStateUrl {
url: string;
path?: string[];
params: Params;
queryParams: Params;
breadcrumbs: Breadcrumb[];
}
adds a new field - breadcrumbs
For the whole store I have a reducer map like this:
export interface State {
router: fromRouter.RouterReducerState<any>;
//... other feature states
}
export const reducers: ActionReducerMap<State> = {
router: fromRouter.routerReducer,
// ...other feature reducers
};
I would like to manipulate the custom part of my router state( the breadcrumbs field). Is there a standard way of extending the routerReducer in a way that will allow changing the custom field?
UPDATE: One possible workaround I see is to create a separate feature in the store for breadcrumbs, keeping router state feature pure. That would require the new feature to reduce router actions. To my mind, this is a hack though. It seems illogical that router state allows extending the state with extra fields, but not the reducer
It isn't possible (at the moment) to add custom actions to the built-in router reducer.
Depending on what you need you can either: