Conclusion

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

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.ktgetProfile() and postReview(). See you there. :]

See forum comments
Download course materials from Github
Previous: Demo Next: Quiz: Use retrofit with coroutines