I am doing my first steps with RxJava und Retrofit. I have a rest API which returns an Observable<Department>
. The class Department
has a nested list of Team
objects. How can I get an Observable<Team>
which delivers all teams of the nested list from the Observable<Department>
?
I tried playing around with map()
and switchMap()
but I still can't get the desired Observable<Team>
.
My idea is to subscribe to the Observable<Team>
and for every delivered team I trigger some update logic.
You can just create a pipeline using map to get the inner values and then flatMapIterable to unwrap the arrays.
Suppose dept$
is your Observable<Department>
dept$
.map(d -> d.getTeam())
.flatMapIterable(teamArr -> teamArr)
.doOnNext(System.out::println)
.subscribe();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.