Jan
01/25/2022, 5:35 PMclass AbsenceViewModel : ViewModel() {
val absencesFlow = MutableStateFlow<List<DBItem>>(emptyList())
init {
viewModelScope.launch {
kotlin.runCatching {
AbsenceRepository.getAll()
}.onSuccess {
absencesFlow.value = it.toList()
}.onFailure {
absencesFlow.value = emptyList()
}
}
}
}
but whats when I modify the entries on the rest api? Or if I want to modify them locally?val viewModel by viewModels<AbsenceViewModel>()
val entries by viewModel.absencesFlow.collectAsState()
What if the entries in the rest api change or I like create a new entry and want to add it to the "entries"?