PHondogo
11/13/2024, 9:55 PMStylianos Gakis
11/13/2024, 10:03 PMPHondogo
11/13/2024, 10:13 PMChristopher Mederos
11/13/2024, 11:46 PM@Composable
private fun MyList(viewModel: MyViewModel) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
LazyColumn {
items(
items = uiState.myItems,
key = { myItem -> myItem.id }
) { myItem ->
// rendered composable
Text(myItem.name)
// func in your VM that will load/unload uiState.myItems
// as a result of this ID being rendered
viewModel.registerSeenId(myItem.id)
}
}
}
If you don't want to do that yourself, then there is an integrationa vailable with the paging library as well -
https://developer.android.com/develop/ui/compose/lists#large-datasets