Currently I have in my AuthGuard constructor a subsription to redux state change below. It will just redirect to original page requested after login. This is not correct place but i don't know where it should be:
auth.guard.ts:
this.subscription = this.ngRedux.select<ILoginState>('login')
.subscribe(newState => {
if (newState.isLoggedIn) {
let redirectUrl : string = ngRedux.getState().window.windowData.redirectUrl;
if (!redirectUrl) {
redirectUrl = '/map/' + this.tabService.sessionId;
}
this.router.navigate([redirectUrl]);
}
});
I have also other navigation related stuff like below. This is currently in a service that is supposed to manage different browser windows and state syncing across them:
/* track url changes and change redux state */
this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
this.ngRedux.dispatch(this.windowActions.setOutletActiveRoute(event.urlAfterRedirects));
}
});
Both could be in new navigation-service.ts in core or in app.component.ts. I read an article about not subscribing in angular service so maybe not service. Also putting everything in app.component sounds bad idea. I would like to put all navigation related stuff to it's own place to separate concerns. What would be recommended way?