In my Ionic 5 project, I have ngOnDestroy()
for the service classes to clean up data. I also have ngOnDestroy()
on my Home page. When I do the following navigation from the Home page to Page A and back to the Home page the ngOnDestroy()
for Page A is triggering.
- Home page -> Page A
- Home page <- Page A
The issue is when I close the app I am expecting the ngOnDestroy()
on the Home page and all the service classes to be triggered but that is not happening. I see the following is mentioned in the Ionic documentation.
ngOnDestroy will only fire when a page "popped".
I checked that even ionViewWillLeave
is not triggering on Home page when the app is closed. Please suggest how do I do clean-up activity in the Home page and services?