does anyone have a good article explaining how to ...
# android
does anyone have a good article explaining how to use retrofit with coroutines and MVVM architecture
A lot of articles just launches the coroutine from activity, my goal is to launch from view model and return a value to view
what we use is an activity-viewmodel-usecase-repository structure. Briefly, the viewmodel extends
so it can use
scopes to run coroutines methods that are defined in the use case as suspend functions. The suspend functions then use
return withContext(<http://Dispatchers.IO|Dispatchers.IO>) { // your api call }
to actually perform retrofit calls. The ViewModel then uses the returned value from the use case as a livedata that the activity observes
@nicopasso do i need to use JakeWharton/retrofit2-kotlin-coroutines-adapter for making api calls from within withContext
@Ive Vasiljevic we're not using it for now but yea I'd say that it's defintely something you wanna use