I am attempt to observe on java.lang.Void but my 2...
# android
r
I am attempt to observe on java.lang.Void but my 204 responses are still coming back with null pointer exceptions: https://gist.github.com/pymblesoftware/30a26505af653a495f95983ad1528958 How do I handle 204s..?
r
Try using
Unit
instead of
Void
. You can't have
null
items in your stream in RxJava2, so you can't get emissions from
Observable<Void>
.
r
ah no, I think I originally tried observing on Unit and I just tried again but that also comes back with the same null pointer exception. I may have to shelve it and move onto other code and come back to it...
r
@Regan Russell, you can use Observable<Response<Void>> instead Observable<Void>
and check answer code from response like this protected boolean convertResponseCodeToBoolean(Response<?> response) { return (response.code() >= 200 && response.code() <= 299); }
r
cool, hang on a a sec I have to stash some stuff and I will check it out.
Cool, I see a response 204 in the raw response now.. Awsome, thanks.
r
You're welcome
r
Completable?
g
@Regan Russell +1 for Completable But if you still need Unit you can use this approach: https://github.com/square/retrofit/issues/2329#issuecomment-301316873
r
Thanks.