I tried to use RemoteMediator to fetch data from an API and cache the response, and generally it works great.
I need something a bit different than the normal behaviour. by default it seems it automatically fetches cached data first (from room) and only when it reaches the end of the list, it performs another request. To make sure that you get fresh data, I saw in the docs that I have to clear the cached data every time the user makes a new search (in order to invalidate the flow and update the RecyclerView's list).
What I want to do is to always perform an API request (if the user have internet), and use the cached data only if he doesn't have an internet connection (the cached data needs to be persisted, so I can't delete it because I need to use it as a foreign key with other entities in the database).
Any suggestions are appreciated. Thanks!