rx-java2 - RxJava:链接两个平面图
问题描述
我有一个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
。我没有弄清楚什么是正确的语法?
解决方案
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。
推荐阅读
- vba - 关于 PPT 上的缩放形状
- javascript - 尝试根据它们是偶数还是奇数来将数组中的值相乘
- c++ - 如何在 C++ 中将字符串数组转换为整数数组?
- linux - libc syscall(),受益于传递电话号码?
- ios - Swift / Objective C:有没有办法找到某种类型的所有对象?
- html - 这张表是否可以在 HTML 中使用
- php - 使用 MySQL 数据库进行 PHP 导航
- reactjs - 为什么我不能从路径中获取图片
- swiftui - NavigationLink 在导航到另一个视图时可以执行异步功能吗?
- java - 为什么日期输出看起来像这样(预期结果和实际结果之间的差异是一个小时)?