I am new to the paging library 3.0, I need to paginate data only from the local database. Initially, I fetched PagingSource<Int, MessageDisplayModel> from the database and use it as flow.
fun getChatMessages(chatWrapper: ChatWrapper): Flow<PagingData<MessageDisplayModel>> {
return Pager(
config = PagingConfig(pageSize = 15,
maxSize = 50,
enablePlaceholders = true)
) {
xmppChatManager.getChatMessages(chatWrapper)
}.flow
}
Then after PagingData is passing to the adapter through submitData() method.
lifecycleScope.launch {
@OptIn(ExperimentalCoroutinesApi::class)
mViewModel.getChatMessages(chatWrapper).collectLatest {
adapter.submitData(it) }
}
Now, my concern is how can we get the actual list of MessageDisplayModel from PagingData which I pass to the adapter?