I have a service (LocationService) that contains the user's country based on his gps coordinates and the functions to get the gps coordinates and do the reverse geocoding. My idea is to use the service to store the country and if the value is null then execute the function that gets the country.
I want to store it on a service because on my routes I call services that call the LocationService before performing any api call.
As I need to do this on all my routes is it any way to check if I have the country stored on the service, or if it's not the case get user location, before loading any route? Like a guard that checks if the user is logged.
The other alternative would be to set a function on the ngOnInit of every smart component of each route.