Retrofit and Coroutines
The old way of making network calls with Retrofit utilizes callbacks. In this course, learn how to greatly simplify Android networking code with an app that retrieves and displays a list of GitHub repositories. By Fuad Kamal.
This is part of the Advanced Android Data & Networking learning path. View path.
Who is this for?
Developers who want to use the modern approach of writing asynchronous network calls. It expects you to be familiar with Android Studio and Kotlin programming. Familiarity with Retrofit would be helpful but is not required.
- Retrofit networking library
- Using coroutines with Retrofit to make network calls.
- Converting callback style code to coroutines
Part 1: Retrofit
Review retrofit and what related libraries can be used for data conversion. Then, add the necessary dependancies to the Gradle and synchronize the project.
Set up an interface that lets Retrofit connect to the GitHub API.
Create a class to implement the Github service and use it to fetch data.
Make a retrofit network call the old way using callbacks.
Part 2: Coroutines
Learn how coroutines make asynchronous code read like synchronous code. Understand how coroutines handle threading for you and coroutine scope.
Update the traditional Retrofit code from the previous episode to instead use coroutines.