Is there any way (or heck) to modify paging (3) da...
# compose
r
Is there any way (or heck) to modify paging (3) data to show ui changes in compose? Like modifying certain object property from paging list when user interact with ui. Paging doesn't seems to support data modification.
a
I just map the PagingData into a UI model, then I keep my own ui state from ViewModel
like having a list of checked items’ ids
r
Can you please share some sample code? That would be very useful
Simple GitHub gist would be fine 🙂
s
if you use room-based paging source, you can update this item in database. then your paging flow will emit a change
r
Hi, I don't want to use room base paging source. I just want to use network response without database caching.
s
modyfing items without db is kinda hard - I suggest a simple dao with room fallback to destructive migration, if you don’t care about the tables
r
But inserting items in db is time consuming for lots of data, thus creating delay in ui. That's why I want to avoid it
Also, please explain in a bit about this simple dao approach
s
I was in your position a while ago, I also tried not to use room, but I’m pretty glad I did. time between clicking update button and seeing viewholder update is like 0.1s I guess
r
@solidogen will it work in case I want to always get latest data from network (and save to db only when app is running, once app is restarted, data should be fetched from network) ?
s
yes
Copy code
override suspend fun initialize(): InitializeAction {
        // Require that remote REFRESH is launched on initial load and succeeds before launching
        // remote PREPEND / APPEND.
        return InitializeAction.LAUNCH_INITIAL_REFRESH
    }
refresh = refetch all data from network
r
Thanks 👍 I'll use it then