Has anyone use MVI arch, Jetpack Paging in CMP? ``...
# compose
o
Has anyone use MVI arch, Jetpack Paging in CMP?
Copy code
@Immutable
data class GalleryUiState(
    val galleryImagePagingData: Flow<PagingData<GalleryImage>> = emptyFlow(),
    val eventSink: (GalleryUiEvent) -> Unit = {},
) {
    companion object {
        val Empty: GalleryUiState = GalleryUiState()
    }
}
Currently, I have to use
Flow<PagingData<GalleryImage>>
inside of the UiState, but I don't think this is a good practice. If I use
PagingData<GalleryImage>
instead, which cause me unable to use
collectAsLazyPagingItems()
in the Composable function. Full project here https://github.com/Omico/picsum I saw Chris circumventing this by using Circuit, but it seems like a better design pattern is needed if we want to achieve it without using Circuit. https://github.com/chrisbanes/tivi/blob/a0c62c2c763c83e3a0ecf79b283224374bb06c4a/u[…]ommonMain/kotlin/app/tivi/home/popular/PopularShowsPresenter.kt
👀 1
t
PagingData<T>
is really a wrapper for
Flow<List<T>>
, so it should really not be used in MVI setups and should be collected independently.
Flow<PagingData<GalleryImage>>
might as well be
Flow<Flow<List<GalleryImage>>>
o
That's so weird. In the end, it forces us to do the same thing that Molecule or Circuit did.