https://kotlinlang.org logo
#android
Title
# android
r

Regan Russell

09/24/2017, 10:37 PM
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

russhwolf

09/24/2017, 10:44 PM
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

Regan Russell

09/24/2017, 11:03 PM
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

Reyst

09/24/2017, 11:37 PM
@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

Regan Russell

09/24/2017, 11:42 PM
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

Reyst

09/24/2017, 11:45 PM
You're welcome
r

russellkim

09/25/2017, 2:02 AM
Completable?
g

gildor

09/25/2017, 2:06 AM
@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

Regan Russell

09/25/2017, 3:05 AM
Thanks.
2 Views