I have an Angular / Ionic 5 app with a view which shows a video stream. From this view, we can navigate to:
Views which get pushed onto the stack. This way the video will simply continue running in the background, which is great and intended,
Navigate back or navigate to other views via
routerDirection="root"
, where the video view is popped from the stack, and thus the video will stop running.
We want to avoid that the user accidentally disconnects from the video in case (2), by showing a confirmation dialog.
This would obviously typically be done through a CanDeactivate
guard. However, this guard currently shows both, in case (1) and (2).
Is there any way to detect (within the guard, or elsewhere) if the navigation would remove resp. pop the current view from the stack, so that I can act accordingly and only show the dialog in this case?
[edit] The solution presented here using the NavController
’s direction
seems like a good start, however this does not cover push/pop events 1:1 unfortunately.