Created
April 7, 2020 15:16
-
-
Save blessedbyjobs/6cdfc280d7951534e8f8ad182d81d328 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Category(val id: Int, val name: String, val subCategories: List<SubCategory>) | |
data class SubCategory(val name: String) | |
data class Product(val value: Int, val category: SubCategory) | |
private fun getSubCategories(id: Int) = Observable.just(categories.first { it.id == id }.subCategories) | |
private fun getProductsByCategories() { | |
getSubCategories(categoryId) | |
.flatMap { categories -> products.filter { it.category in categories }.toObservable()} | |
.subscribe { Log.i("Products: ", it.toString()) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment