Omico
05/09/2025, 1:10 AM@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.ktTunji Dahunsi
05/09/2025, 2:53 AMPagingData<T>
is really a wrapper for Flow<List<T>>
, so it should really not be used in MVI setups and should be collected independently.Tunji Dahunsi
05/09/2025, 2:54 AMFlow<PagingData<GalleryImage>>
might as well be Flow<Flow<List<GalleryImage>>>
Omico
05/09/2025, 5:37 AM