FunkyMuse
01/14/2021, 8:01 AMLukas Sztefek
01/14/2021, 8:07 AMprivate val stateData = MutableStateFlow(State.Idle)
val state: StateFlow<State> = stateData.asStateFlow()
The only reason – I don’t like syntax of getters and setters in kotlin.Javier
01/14/2021, 8:08 AMFunkyMuse
01/14/2021, 8:08 AMLukas Sztefek
01/14/2021, 8:09 AMJavier
01/14/2021, 8:13 AMFunkyMuse
01/14/2021, 8:16 AMJavier
01/14/2021, 8:20 AMFunkyMuse
01/14/2021, 8:24 AMJavier
01/14/2021, 8:32 AM// ViewModel
private val _state = MutableStateOf(...)
val _state: StateFlow<> = _state
// Fragment
(viewModel.state as MutableStateFlow).value = ...
FunkyMuse
01/14/2021, 8:35 AMJavier
01/14/2021, 8:35 AMasStateFlow
you can't do that because it should crash. But I have never tried that casting personally, with our without asStateFlow
asStateFlow
instead of the other oneRuckus
01/14/2021, 3:39 PM