Last active
January 24, 2019 00:58
-
-
Save naturalwarren/c96fd674b0b91e24c117ef1f263d793f to your computer and use it in GitHub Desktop.
Making a Retrofit API call with RxJava with a Kotlin-esque API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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