Reputation: 60184
I have a List
of data models, User
in the example below, returned from a webService
(Retrofit). I split the List
into elements and emit them one by one so to filter
them somehow. Then I need to combine all filtred User
s and create a List
of them. Please check out the code below so it is more clear.
webService.getUsers() // returns Observable<List<User>>
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMap(users -> Observable.from(users)) // split the collection of Users, so we can filter them next step
.filter(user -> user.getId() % 2 == 0) // get only Users with even id
// How to transform from here to have a List<User> ?
Upvotes: 1
Views: 1823