https://kotlinlang.org logo
#flow
Title
# flow
e

elye

12/22/2021, 4:57 AM
Hi, I have a question We can create LiveData or StateFlow in a similar way as below
Copy code
val _liveData = MutableLiveData(0)
val _stateFlow = MutableStateFlow(0)
But In LiveData, we can ensure the data is saved and restored by using
Copy code
val _liveData: MutableLiveData<Int> = savedStateHandle.getLiveData("Key", 0)
For StateFlow, is there a way (or API) to keep the last value and restore it, like what we have in LiveData?
👆 1
j

Jan Skrasek

12/22/2021, 10:27 AM
2 Views