I am working with ngrx/router-store 8. This version exposed the "@ngrx/router-store/request" action which include a navigationTrigger in its payload:
type: '@ngrx/router-store/request',
payload: {
routerState: {
url: '/directory',
queryParams: {},
params: {},
navigationTrigger: true
},
event: {
id: 2,
url: '/jobs',
navigationTrigger: 'imperative',
restoredState: null
}
}
}
The navigationTrigger can get one of two values:
- imperative - for direct access to a page (by clicking on a link)
- popstate - when using the browser back/forward buttons
I need to know at any time how did I get to the current page so I need access to this variable. The problem is that the build-in reducer of router-store doesn't keep this variable in the state and it only shows at the payload of this action. I realize that I need to override the default reducer but I got no idea how to do this and couldn't find any information on this. Maybe there is another idea how to store this data?
You can listen to
ROUTER_REQUESTinside an@Effect. In your payload, you will probably have the information.