having this `UiState`: ```sealed interface MainScr...
# compose
p
having this `UiState`:
Copy code
sealed interface MainScreenUiState {
    object Loading : MainScreenUiState
    data class Error(val throwable: Throwable) : MainScreenUiState
    data class Success(val data: List<BusStop>) : MainScreenUiState
}
and this method of my `viewmodel`:
Copy code
fun getBusStops() {
    viewModelScope.launch(Dispatchers.Main) {
        launch(<http://Dispatchers.IO|Dispatchers.IO>) {
            busDataRepository.updateBusStops() //updates local database with retrofit new data if available
        }
        val busStops = busDataRepository.getBusStops() //returns Flow<List<BusStop>>
        //TODO update uiState with new busStops
    }
}
how can I initialize my uistate variable with local data if exist (empty if not) and update it with new data when
getBusStops()
of the viewmodel gets called by ui?
Copy code
val uiState: StateFlow<MainScreenUiState>
t
I would say that this datamodel is a little bit off for your usecase. Because it can only show loading or error and success. Maybe you should have a boolean for loading and than this sealed interface for the two possible states after loading. Or you just rename the Loading state to a data class that can hold the local data.