Single.zip with Completable

PGu*_*ler 5 rx-java

这是我的问题:我有一些单身,想要拉链.但我只希望在Completable完成后调用zip函数.另外,我想同时订阅所有单曲和Completable.(所以没有completable.andThen(Single.zip(...))

这是我现在正在做的一个例子:

Single<T1> s1 = …;
Single<T2> s2 = …;
Single<T3> s3 = …;
Completable c = …;

Single.zip(s1, s2, s3, c.andThen(Single.just("")), (a, b, c, ignore) -> {
// All singles have emitted an item and c is completed
 …
})
Run Code Online (Sandbox Code Playgroud)

有没有更好的办法?

aka*_*okd 12

你可以使用toSingleDefault从转换时CompletableSingle:

Single<T1> s1 = …;
Single<T2> s2 = …;
Single<T3> s3 = …;
Completable c = …;

Single.zip(s1, s2, s3, c.toSingleDefault(""), (a, b, c, ignore) -> {
// All singles have emitted an item and c is completed
…
})
Run Code Online (Sandbox Code Playgroud)