RxJava2:Observable的替代<Void>

chr*_*rjs 7 android rx-android rx-java2

我有一个API,只返回错误/成功代码,没有正文.使用RxJava1,我将用作Observable<Void>此调用的返回值.

我可以为RxJava2使用什么?Wiki上对RxJava2(链接)的提示没有帮助,因为我无法更改API的工作方式.

建立:

compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
Run Code Online (Sandbox Code Playgroud)

Gra*_*and 25

使用Completable.

如果操作成功,它将发出成功的终止事件.如果失败,您可以使用自己的Exception子类来包装必要的错误代码.