Im investigating Kotlin MutableStateFlow
/StateFlow
and would like to declare my MutableStateFlow
in a Generic Base Class as follows:-
class MyBaseClass<S> {
private val internalState = MutableStateFlow<S>(//WHAT GOES HERE????//)
val state: StateFlow<S>
get() = internalState
}
The issue I am stuck with is that MutableStateFlow has a mandatory initial value.
I cannot see how to provide a generic initial value of Type "S
"
Is it possible to use this approach of employing a generic base class instance variable?
` indicating the default value, and then just pass that to `MutableStateFlow– Lino Sep 01 '20 at 09:08()`?