How to simplify MVVM Repository function using Room and Retrofit
Below is ViewModel class and Repository class of Android MVVM design pattern.
(1) ViewModel calls a function of Repository in Coroutine.
(2) Then Repository checkes data in SQLite.
(3) If there is no data in SQLite, request data using Retrofit.
(4) After retrieve data from Retrofit, the data is saved in SQLite and sent to ViewModel.