Kotlin Coroutines Code Example: Refactor Retrofit Call

preview_player
Показать описание
In this hands on code example, I demonstrate Kotlin co-routines: launch, async, and await. I show how co-routines can make parsing JSON with Retrofit incredibly simple, by removing the need for call and enqueue. I walk through several exampls in the debugger, invoking a Service class from a ViewModel with the KTX viewModelScope feature. That ViewModel uses the launch co-routine to invoke a service class that invokes a JSON parse. I refactor the JSON call to use async, and then I use await to use the object results of that JSON call in another suspend function.

Рекомендации по теме
Комментарии
Автор

I'm learning a lot from you Mr. Jones. Thank you very much.

faridlotfabadi
Автор

Dude that was by far the best explaination I found on that topic! Your other videos are also great! You clearly understand what you are talking about and don't just write down some copied code! Keep up :)

qwed
Автор

Hello professor, i've got a question regarding this lesson. At 11:10, on the breakpointed line you clicked on plants and was able to see whole response body. If i may ask, how did you achieve that? It would be really useful in some of my own projects. Thank you very much

gra_nn
visit shbcf.ru