繁体   English   中英

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

[英]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() responseList<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.

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