Member-only story
StateFlow with Jetpack Compose
Alternative of LiveData
Recently I have heard that StateFlow will replace LiveData. StateFlow and LiveData have similarities and both are observable. Let’s know about it more.
What is StateFlow
According to official documentation
StateFlow is a state-holder observable flow that emits the current and new state updates to its collectors. The current state value can also be read through its value property. To update state and send it to the flow, assign a new value to the value property of the MutableStateFlow class.
We will learn it with a basic example.
What are we Reading
It’s a great app. Isn’t it? 😉
Let’s Start
First, create a ViewModel.