You can listen for the lifecycle of the NavDestination component through Class (UIObserver). For details about the lifecycle, see the following document. Since API version 17, the onActive and onInactive lifecycles are added. The onInactive and onActive lifecycles of the lower-layer page are triggered when dialog is displayed or destructed, respectively.
Reference