package com.example.smart.ui.project.inspect
|
|
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.viewModelScope
|
import com.example.basecore.base.BaseContextViewModel
|
import com.example.basecore.net.http.Result
|
import com.example.smart.reqeust.RetrofitClient
|
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.launch
|
|
|
class InspectViewModel: BaseContextViewModel( ) {
|
|
val bean = MutableLiveData<MemberAllBean>()
|
|
|
fun callList(id: String, fail: (String) -> Unit) {
|
viewModelScope.launch(Dispatchers.Main) {
|
safeCall {
|
execute(RetrofitClient.api.inspectList(id)) }.apply {
|
if (this is Result.Success) {
|
bean.value = this.data
|
} else if (this is Result.Error) {
|
fail(exception.message ?: "未知错误")
|
}
|
}
|
}
|
}
|
|
}
|