RxJava:链接两个平面图

时间:2019-07-15 14:38:35

标签: rx-java2

我有一个方法getListFromDatabase()返回了Single<List<User>> users,并且我想做什么:

getListFromDatabase()
.flatMap(// send list to another server)
.flatMap(// check if there are users that I have to added manually from a bundle, here I needs database connexion so I have to do this asynchronously, and I need the list I just retrieved)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(// handle onSuccess, onError etc.)

但是在第一个flatMap中,它一直告诉我missing return statement。我不知道什么是正确的语法?

1 个答案:

答案 0 :(得分:0)

getListFromDatabase()
.flatMap(users -> sendAnotherService().map(ingoreResult -> users))
.flatMap(// check if there are users that I have to added manually from a bundle, here I needs database connexion so I have to do this asynchronously, and I need the list I just retrieved)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(// handle onSuccess, onError etc.)

其中sendAnotherService()返回具有任何arg类型的Single。