I'm using Paging 3 with Room and RemoteMediator
. I haven't set a maxSize
in the PagingConfig
which means that we shouldn't drop pages no matter how far we scroll.
fun getSearchResults(query: String): Flow<PagingData<NewsArticle>> =
Pager(
config = PagingConfig(pageSize = 50),
remoteMediator = SearchNewsRemoteMediator(query, newsArticleDatabase, newsApi),
pagingSourceFactory = { newsArticleDao.getSearchResultArticlesPaged(query) }
).flow
However, I noticed that Room still drops pages when I scroll far enough. I observed that in logcat via an AdapterDataObserver
.
onItemRangeRemoved start: 100 count: 100 end: 199
My question is: Is this expected behavior, or a bug, or some error on my side? If it's expected behavior, what is the maxSize
attribute for? I observed my data with a maxSize
value set but it never removed any entries from the database.
Edit: I now also noticed that Room does not drop pages if we are looking at cached offline data. Why? I would expect it to behave exactly the same.