[英]RxJava filter list inside observable
我有對象
public class Response {
private List<Content> content;
public static class Content {
private boolean rated;
}
}
並且我想按rated
過濾List<Content> content
。 我試圖這樣做
mResponseProvider.reponse()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMapIterable(response -> response.getContent())
.filter(content -> mAAA.isRated(content.getRated()))
.toList()
.subscribe(response -> {
doSomethingWithResponse(response);
});
但是問題是我在.subscribe()
response
是List<Content>
。 如何獲得具有List<Content>
過濾值的.subscribe()
Response
對象?
mResponseProvider.reponse()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.filter(response -> mAAA.isRated(response.getContent())) //1
.subscribe(response -> {
doSomethingWithResponse(response);
});
// 1嘗試將參數更改為isRated中的List
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.