I have this view, that doesn’t recompose, so basically, it never gets past the first line under LazyColumn.
val ecViewModel = getViewModel<ECViewModel>()
val courseListState = ecViewModel.courseList
Scaffold(
topBar = {
TopAppBar(title = { Text("People In Space") })
}) {
LazyColumn(contentPadding = paddingValues) {
courseListState.value?.let { it1 ->
items(
items = it1.courses
) { person ->
CourseView(person, personSelected)
}
}
}
}
In my viewModel I have this:
val courseList = MutableLiveData<CourseCatalog>()
init {
viewModelScope.launch { val courses = ecRepository.fetchCourses { it -> courseList.postValue(it) }}
}
And my repository has:
suspend fun fetchCourses(courseListNavigation: (courseList:CourseCatalog) -> Unit) {
courseList = CourseCatalog(ecApi.fetchCourseCatalog().toList())
courseListNavigation(courseList!!)
}
I only need to call this once as the data is updated only 3-4 times a year and expectation is to later show a view that states the data is loading and when the state changes to show the correct view.
I am using Kotlin 1.4.32, and my libraries for compose are two versions behind the latest, so androidx.compose.us:ui:1.0.0-beta-6.