Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.53 KB | None | 0 0
  1.     override fun <T> mapCarsToFavorites(
  2.         carsList: List<T>,
  3.         findOp: (T, HotDealsResponse) -> Boolean,
  4.         mapOp: (T, HotDealsResponse?) -> T
  5.     ): Flowable<List<T>> =
  6.         database.favoritesDao().getAllFavorites.map { favorites ->
  7.             carsList.map { car ->
  8.                 val matchingCar = favorites.find { favorite -> findOp(car, favorite) }
  9.  
  10.                 if (matchingCar != null) {
  11.                     mapOp(car, matchingCar)
  12.                 }
  13.             }
  14.  
  15.             carsList
  16.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement