https://kotlinlang.org logo
Title
k

Kulwinder Singh

07/30/2020, 12:49 PM
Hi, did anyone worked on Paging 3, i want to know how we can mutate one item from paged list https://stackoverflow.com/questions/63171749/how-can-we-mutate-items-loaded-using-paging-3-android
g

gildor

07/30/2020, 12:56 PM
I suspect it still immutable, same as Paging 2
j

Joost Klitsie

07/30/2020, 2:17 PM
With paging 2 you have to invalidate the entire list
but what you can do is store the list locally, in the paged data source factory for example
• pagination data source loads list and keeps reference to all data (in my case the domain objects before mapping to ui friendly objects) • when you press like button, invalidate the old list • from the pagination factory, fetch the old data from the invalidated list • construct new list with passing the old data • instead of fetching the new data in the initial loading, simply use the old data, which should have the new like state included.
If you pass on the new list to the existing paged list adapter (with submitList) then the paged list adapter will use a list differ to update your list
so if Paging 3 does this the same as paging 2, then this would be a start 🙂
k

Kulwinder Singh

07/30/2020, 3:11 PM
hmm Yeah, looks like i have to store locally
i will try this @Joost Klitsie
c

Chethan

07/31/2020, 6:48 AM
Hi @Kuldwinder Singh, Please check my message in the stack over flow https://stackoverflow.com/a/63187011/1407554