I have a sealed-class like this
sealed class LoadState {
class Loading : LoadState()
class Success : LoadState()
class Fail : LoadState()
}
I use sealed-class with LiveData, it works
open class BaseViewModel: ViewModel() {
// val loadState by lazy {
// MutableLiveData<LoadState>()
// }
val loadState by lazy {
MutableStateFlow(LoadState())
}
}
but when I change MutableLiveData to MutableStateFlow, I get a warning like this
Sealed types cannot be instantiated
so, how to use sealed-class in MutableStateFlow?