Skip to main content
2 of 2
fixed several issues with the provided code
tyg
  • 13.5k
  • 4
  • 33
  • 45

you can try using StateFlow something like this: Your ViewModel

private val _repDataPoints = MutableStateFlow<List<RepDataPoint>>(emptyList())
val repDataPoints = _repDataPoints.asStateFlow()

Your Composable:

val list by viewModel.repDataPoints.collectAsStateWithLifecycle()

And finally to modify repDataPoints value you can do something like that:

fun addNewValue() {
    _repDataPoints.update { it + RepDataPoint() }
}

I think the problem is your list that you have in you viewmodel cant notify to your composable and never recompose

witodev
  • 138
  • 3