Has anyone used the android paging library with ro...
# multiplatform
t
Has anyone used the android paging library with room in a kmp library shared by android and ios that is not a compose multiplatform app? We have things working great on the Android side but are having trouble finding or building a
collectAsLazyPagingItems()
equivalent for swift ui
Additional details from our iOS engineer:
How would y'all recommend consuming a
Flow<PagingData<T>>
for an iOS client that needs a stable list of elements and that will use native iOS components for its UI? It needs to manage updating the list value when insert/delete/modify updates are made to elements in the list? I have tried creating a
PagingDataPresenter
and using that + a cached list, and have found that paging3 is quite coupled to Compose and there is a great deal of complexity in mapping to a stable list, since the
snapshot()
is scoped to a 'visible window' of the backing Room table.
I've found that
AsyncPagingDataDiffer
does not have KMP support. I am thinking that I will just make a new Dao query to pass a
limit
and
offset
, and returning a
Flow<List<T>>
for each page using
distinctUntilChanged()
. It seems that this direction would be less complexity than trying to map the
PagingData
for an iOS client. Does anyone have experience trying to solve this problem?
r
Do not couple your application to a library; create your own classes, interfaces, and any strategy that works for you (in clean architecture, these would be called your domain objects). Then, for your use of Room, create a mapping, and for each UI platform, create a mapping as well.
t
Yeah, we have discussed that and agree it would be ideal but would be a pretty big shift in how our apps work currently. Also, doesn't really relate to the problem we are facing with paging right?
r
Maybe, your current problem as I understand are usage of paging in swift ui platform. If you design an abstract container with your requirements in common main code and map it to platform specific maybe be a solution. I can't give you a direct recommendation because I don't have access to a Mac and I'm not familiar with Swift.