Pablo
12/16/2024, 11:35 AMval uiState: StateFlow<BusStopsDBScreenUiState> = busDataRepository.getBusStops()
.map<List<BusStop>, BusStopsDBScreenUiState> { busStops ->
BusStopsDBScreenUiState.Success(busStops, Res.string.bus_stops_db_filled)
}
.catch { throwable ->
emit(BusStopsDBScreenUiState.Error(throwable))
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), BusStopsDBScreenUiState.Loading)
getBusStops returns a flow
@Query("SELECT * FROM BusStops")
fun getBusStops(): Flow<List<BusStopEntity>>
Seri
12/17/2024, 4:34 PMfun getBusStopsSnapshot(): List<BusStopEntity>
would get you a single, non-reactive result.Pablo
12/18/2024, 12:23 PM