I have a location sensor in my app that gets triggered when someone taps the location symbol button on the screen.
I want to update a variable from an API call once and then every 5 minutes after the location button is tapped. I know the basics of how to do this but I want to avoid having the button tap trigger overlapping 5 minute refreshes of the data.
Here’s how I’ve thought about structuring it:
But I’m worried that if you tap the button and then tap it again 5+ minutes later, it will start a new forever loop AND keep the first forever loop going thereby having two API calls every 5 minutes, etc.