Hieu Truong
07/11/2023, 5:07 AMPagingData<Model>
and a Flow<Boolean>
and result in PagingData<UiModel>, and finally show up in a LazyColumn via collectAsLazyPagingItems()
.
In LazyColumn
:
val assetPagingData = viewModel.pagingFlow.collectAsLazyPagingItems()
...
items(
count = assetPagingData.itemCount,
key = assetPagingData.itemKey { it.id }) {
val item = assetPagingData[it]
if (item != null) {
AssetItem(item = item) {
}
} else {
Text(text = "Item null")
}
}
In `ViewModel`:
pagingFlow = getDataUseCase.execute(param)
.combine(masterDataModelStateFlow) { pagingData, masterDataModel ->
pagingData.map { pagingModel ->
UiModel(
pagingModel = pagingModel,
masterDataModel = masterDataModel,
)
}
}.combine(getVisibilityFlow) { uiModel, show ->
uiModel.map {
it.copy(showBalance = show)
}
}.cachedIn(coroutineScope)
After I change the Boolean value, it triggered combine()
again, I expected that mapping PagingData<Model>
one more time to get new PagingData<UiModel>
but it does not recompose the LazyColumn
to get new UI available.
What did I miss?
Thanks.