How to start executing a block of code after changing the value of LiveData when using .observeAsState()?
Example: LivaData changes and after need to call Toast.
>Solution :
If you are using Jetpack Compose then the composable, which observes LiveData as state, will be recomposed each time the state changes.
The thing is that compose provides us with automatic recomposition when it has some kind of changeable state of type State<T>.
Recomposition means that your composable function will be called again.
liveData.observeAsState() converts livedata with type T to an object of type State<T>
It means that you can do something like this:
@Composable
fun MyMethod() {
val data by liveData.observeAsState()
...
Toast.makeText(...)
}