As far as I understand it the CanActivate interface in Angular2 is only effective on route changes. So if I have a page p that requires the user to be logged in I can create a guard that implements the CanActivate interface which will allow the RouterModule to activate p only if the user is logged in.
But what happens when p is active and the user gets logged out? I have tried to find best practices on checking if a page is allowed to be active without changing the route in the RouterModule but I can't find anything useful. Lets say page p is active and requires a login. Now a logout is triggered somehow while p is active but no route change is involved. Lets say the server responded with a 401 and the app notices the user is not logged in anymore. What would be the best practice to check if the active page requires a login and take measures accordingly? It could be that the active page does not require a login. In that case everything should remain as it is.