<How to collect the initial value of StateFlow> I'...
# stackoverflow
u
How to collect the initial value of StateFlow I'm trying to substitute Android's LiveData with StateFlow. With LiveData, every time I observe it I always get the latest value. class MyViewModel { private val _myLiveData = MutableLiveData("value") val myLiveData: LiveData = _myLiveData } class MyFragment : Fragment() { ... override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) viewModel.myLiveData.observe(viewLifecycleOwner, { println(it) //...