Using the following objects :
Order {
int orderId;
List<Item> items;
}
Item {
int price;
String description;
boolean free;
}
The goal is to keep non-free items starting from an Observable<0rder> and still return an Observable<0rder>.
I'm doing the following for now, but my items doesn't get filtered :
getMyOrder() // returns Observable<Order> from the network
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.computation())
.flatMap(
order -> Observable.from(order.items)
.filter(item -> !item.isFree())
.map(items -> order)
);