将嵌套网络回调转换为RxJava2

时间:2017-12-22 20:30:00

标签: java rx-java2

我目前必须在一个丑陋的嵌套回调模型中实现,我是RxJava的新手,我想使用RxJava来解决这个问题。

远程数据源:

1st <> if the client is connected to remote db
    // yes, continue to check sign in
    // no, error, no connection
2nd <> if the user is signed in (user)
    // yes, continue to get user uid from (user)
    // no, error, user not signed in
3rd [] get uid from user
4th [] query user's items with uid
5th <> if query contain items (items)
    // yes, return a Flowable<list<item>>
    // no, return an empty list

每个步骤都是按顺序运行。我认为功能上第一步应该是Completable,第二步应该是Single返回一个User对象,但是我要求第5步将Flowable列表作为下游订阅者的最后一个observable。

给出上面的设计是可行的吗?我应该使用哪些运算符或转换从Completable更改,然后链接另一个Single操作,然后最终是Flowable?

0 个答案:

没有答案