In my Angular 7 project, I've implemented a functionality where routing opens pages in new browser tabs, and the associated router links are stored in the browser's LocalStorage. However, I'm facing a challenge in efficiently detecting and removing these stored router links when users close an open tab.
I need a solution that doesn't involve implementing this condition in every component file, as there are approximately 100 files to update. Is there a recommended approach or a way to centralize this functionality across the application?
I've considered using a service or a global event listener to track tab closure events and manage the LocalStorage data accordingly. However, I'm unsure about the best practice in Angular 7 to implement this without extensive changes to multiple files.
Any insights, examples, or guidance on achieving this in a scalable and maintainable manner across the application would be highly appreciated.
I tried @HostListener.