Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RxJava2: Alternative to Observable<Void>

I have an API which returns only error/success codes, with no body. With RxJava1 I would have used Observable<Void> as the return value for this call.

What can I use for RxJava2? The hint on the Wiki for RxJava2 (link) is not helpful, since I can't change how the API works.

Setup:

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'
like image 380
chrjs Avatar asked Feb 07 '17 15:02

chrjs


1 Answers

Use Completable.

If the operation succeeds, it will emit a successful termination event. If it fails, you can use your own Exception subclass to wrap the necessary error codes.

like image 83
Graham Borland Avatar answered Nov 10 '22 00:11

Graham Borland