getMoreData() in ViewModel is called from outside of ViewModel, everytime user scroll to the bottom of RecyclerView.
fetchMore() in Repository returns a LiveData with LoadingStatus object which contains loading/success/failure and error message
How can I set the loadingStatus variable in ViewModel so that it can be observed properly by the Fragment?
Note: getMoreData() in ViewModel can be called multiple times as the user scrolls down.
ViewModel{
val loadingStatus
fun getMoreData(){
repository.fetchMore()
}
}
Repository{
fun fetchMore() : LiveData<LoadingStatus>{
}
}
Fragment{
viewModel.loadingStatus.observe()
}