package com.example.smart.widget import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import com.example.basecore.base.BaseContextViewModel import com.example.basecore.net.http.Result import com.example.basecore.util.ToastUtils import com.example.smart.MyApp import com.example.smart.bean.CommonOptionsBean import com.example.smart.reqeust.RetrofitClient /** * @author: dai hang * @data: 2024/6/2 15:50 * @description: */ open class CommonOptionViewModel : BaseContextViewModel() { open fun callOption( path: String, bean: MutableLiveData>, id:String = "" ) { launchOnUI { safeCall { callList(RetrofitClient.api.callOptions(path, id)) }.apply { if (this is Result.Success) { bean.value = data } else if (this is Result.Error) { ToastUtils.showToast(MyApp.app, exception.message ?: "未知错误") } } } } }