Sudhir Singh Khanger
09/15/2020, 10:45 AMgildor
09/15/2020, 11:11 AMSudhir Singh Khanger
09/15/2020, 11:20 AMflosch
09/15/2020, 11:28 AMwithContext(Dispatcher)
for coroutines, flowOn(Dispatcher)
for Flow.
In your use-case you would have a suspending function in your repo that runs on IO but is launched in the viewmodelScope
Rechee Jozil
09/15/2020, 3:33 PMSudhir Singh Khanger
09/16/2020, 5:07 AMBut... You seem to want to have some caching mechanism? You sure you need Coroutines for that?I don't need Coroutine for caching. I need it for running a background task. The idea is that a suspend function downloads the data and then I keep it in a LiveData object in the Repository itself. As long as the repository is alive the user would always see the data. It can navigate out of the view and then come back and the data would be there. The API won't be called over and over every time the user visits the UI.
gildor
09/16/2020, 5:22 AM