https://kotlinlang.org logo
#getting-started
Title
# getting-started
o

oday

10/19/2018, 8:11 AM
like so
Copy code
override fun fetchAndSaveFavorites(): Observable<List<FavoriteCars>> {
        val favoriteCars = mutableListOf<FavoriteCars>()

        return carsService.getFavorites().map { response ->
            response.forEach {
                favoriteCars.add(FavoriteCars(listing_id = it.id))
            }

            database.favoritesDao().wipeTable()
            database.favoritesDao().insert(favoriteCars)
            favoriteCars.toList()
        }
    }