Rafiul Islam
08/22/2021, 9:37 AMval name = mutableStateOf("")
instead of using this and viewmodel.name.observeAsState("") in UI.
private val _name = MutableLiveData("")
val name: LiveData<String> = _username
Chrimaeon
08/22/2021, 12:51 PMvar name by mutableStateOf(“”)
private set
to be able to manipulate the name
only from your view model.Oleksandr Balan
08/22/2021, 12:58 PMAdam Powell
08/22/2021, 1:18 PMcorneil
08/22/2021, 1:18 PMStateFlow
or SharedFlow
in your view model to use kotlin coroutines dependent types instead of LiveData
.Adam Powell
08/22/2021, 1:19 PMAdam Powell
08/22/2021, 1:21 PMAdam Powell
08/22/2021, 1:22 PMsnapshotFlow {}
for an exampleRafiul Islam
08/22/2021, 2:14 PMcorneil
08/22/2021, 2:23 PMRafiul Islam
08/22/2021, 3:48 PMcorneil
08/23/2021, 1:21 PMAdam Powell
08/23/2021, 1:30 PMTash
08/23/2021, 5:16 PMYou also lose that consistency if you use StateFlowCould we expand upon this a bit more? This is interesting because
*Flow
APIs have been in line to replace LiveData
in presentation land; I wonder if the snapshot state system is similarly poised as a replacement for *Flow
in presentation land?