【发布时间】:2022-10-14 02:07:05
【问题描述】:
如何在 Completable 上创建一系列 andThen() 运算符?
例如,原始代码是这样的:
return Completable.complete()
.andThen(processdata("01"))
.andThen(processdata("02"))
.andThen(processdata("03"))
.andThen(processdata("04"))
.andThen(processdata("05"))
.andThen(processdata("06"))
.andThen(processdata("07")); //working
它工作得很好!
但我不想要一个“静态”定义的值,并试图将上面的代码转换为:
Completable x = Completable.complete();
String[] allID = {"01","02","09"}
for (String Id : allID) {
x.andThen(processdata(Id));
}
return x; //not working
它不工作,好像什么也没发生
然后我意识到:
Completable x = Completable.complete();
x.andThen(processdata("01"));
x.andThen(processdata("02"));
x.andThen(processdata("03"));
return x; //not working
也不工作...
在我的情况下,任何人都可以帮助如何正确链接 Completable
【问题讨论】:
标签: java reactive-programming rx-java2 reactive rx-java-completable