Making a Retrofit API call with RxJava with a Kotlin-esque API
authApi.getTokens() | |
.subscribe { response : NetworkResponse<AccessToken, Error> -> | |
when (response) { | |
is NetworkResponse.Success<AccessToken> -> { | |
// A 2XX response that's guaranteed to have a body of type AccessToken. | |
} | |
is NetworkResponse.ServerError<Error> -> { | |
// A non-2XX response that may have an Error as its error body. | |
} | |
is NetworkResponse.NetworkError -> { | |
// A request that didn't result in a response from the server. | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment