请问--用mvvm框架,请求在ViewMode中,viewmodel不持有Activity,怎么显示你的loading
Opened this issue · 1 comments
wzqjava commented
请问--用mvvm框架,请求在ViewMode中,viewmodel不持有Activity,怎么显示你的loading
inPeige commented
abstract class BaseViewModel : ViewModel() {
val loading = SingleLiveEvent()
}
abstract class BaseActivity<T : BaseViewModel, VB : ViewBinding> : BaseBindingActivity() {
open fun initObservers() {
addObserver(viewModel.loading) {
if (it) {
showLoading()
} else {
hideLoading()
}
}
}
} `