Hello guys I have a question regarding the flatmap...
# android
t
Hello guys I have a question regarding the flatmap for kotlin and rxjava2. I have an observable of a data class that has a nested list
Copy code
fun getCenterServiceCategories() : Single<CenterServiceCategories>
// ..
data class CenterServiceCategories(
    val meta: MetaResponse,
    val data: List<ServiceCategory>
)
what I want to do The ServiceCategory also has a list of ids that I want to loop through and eventually return a flatmap that has the list of categories with their services embedded. The problem is that I cannot call
Copy code
getCenterServiceCategories().flatmap{ 
//...
}
since the list is actually the data property. i have tried subscribing and getting the data onSubscribe and using Kotlins map and flatmap, but I want to do that with RX any suggestions?
l
Why can’t you do that? inside the
flatmap{}
you can cycle though the list and do whatever you want
☝️ 1
t
Hey Luca, the list I need to loop through is CenterServiceCategories>data
l
Yep exactly, inside the
flatmap{}
you can do
it.data.forEach{}
and cycle through the list