I'm using Android Jetpack's new Paging library to display a list of items received from the API. I want the data on the current page(say page 3) to be refreshed every few minutes without refreshing the whole list with invalidate() function, as this is taking the Recycler view to its first page.
The problem I see here is the Paging library assumes the data is immutable.
https://developer.android.com/reference/android/arch/paging/DataSource#updating-paged-data
On googling, I can see the workaround is to use Room and display the UI based on DB updates from the API call.
Is there any other suggestions to solve this without using a local store.
The only way to get rid of this issue is to introduce a persistence layer with Room. https://github.com/googlesamples/android-architecture-components/tree/master/PagingWithNetworkSample#paging-with-database-and-network
As per docs here : https://developer.android.com/reference/androidx/paging/DataSource#updating-paged-data
If you have more granular update signals, such as a network API signaling an update to a single item in the list, it's recommended to load data from network into memory. Then present that data to the PagedList via a DataSource that wraps an in-memory snapshot. Each time the in-memory copy changes, invalidate the previous DataSource, and a new one wrapping the new state of the snapshot can be created.
https://developer.android.com/topic/libraries/architecture/paging/data#consider-content-updates
As you construct observable PagedList objects, consider how content updates work. If you're loading data directly from a Room database updates get pushed to your app's UI automatically.