简体   繁体   English

里面的RxJava过滤器列表可观察

[英]RxJava filter list inside observable

I have object 我有对象

Response 响应

public class Response {
    private List<Content> content;

    public static class Content {
        private boolean rated;
    }
}

and I would like to filter List<Content> content by rated value. 并且我想按rated过滤List<Content> content Im trying to do this like this 我试图这样做

mResponseProvider.reponse()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMapIterable(response -> response.getContent())
                .filter(content -> mAAA.isRated(content.getRated()))
                .toList()
                .subscribe(response -> {
                    doSomethingWithResponse(response);
                });

But the problem is that my response in .subscribe() is List<Content> . 但是问题是我在.subscribe() responseList<Content> How can I get in .subscribe() Response object with filtered values for 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 try to change argument to List in isRated // 1尝试将参数更改为isRated中的List

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM