This lesson guided you through adding Kotlin coroutines into your networking code.
You’ve learned how Retrofit seamlessly integrates with Kotlin coroutines to make your code
simple, readable, and maintainable. The key takeaways from this lesson are:
— Retrofit supports Kotlin coroutines out of the box.
— Marking Retrofit interface methods with suspend gives you Retrofit-related code generated for
you that also handles threading.
— You can return your custom types directly or wrap them with Response<T> if you need the
response metadata.
— Error handling is done natively with try/catch or runCatching.
— You get a nice syntax in the calling code by using onSuccess and onFailure
extension functions on Result.
In the next lesson, you’ll learn about Interceptors and authentication with Retrofit. You’ll
also implement the two remaining methods in MovieDiaryApi.kt — getProfile() and postReview(). See
you there.
:]
See forum comments
This content was released on Jun 5 2024. The official support period is 6-months
from this date.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: Demo
Next: Quiz: Use retrofit with coroutines
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.