Created
May 18, 2018 06:46
-
-
Save galex/d65d23ff8a4d1766268696555fd5b915 to your computer and use it in GitHub Desktop.
This file contains 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
async(UI) { | |
// before using https://github.com/JakeWharton/retrofit2-kotlin-coroutines-adapter | |
val call: Call<ApiResponse<List<VideoExtra>>> = service.getVideoExtras(userId) | |
val response: Response<ApiResponse<List<VideoExtra>>> = bg { call.execute() }.await() | |
// When using it, our code looks much better | |
val deferred: Deferred<Response<ApiResponse<List<VideoExtra>>>> = service.getVideoExtras(userId) | |
val response: Response<ApiResponse<List<VideoExtra>>> = deferred.await() | |
// using the response's data to set the value of LiveData(), etc... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment