I would like to change livedata to flow. are there...
# android
g
I would like to change livedata to flow. are there some problems? First question... what flow type i have to use.. and collect or ? Example.. a simple navigation with a sealed class. i write code in thread
Inside viewModel
Copy code
private val _navigationState: MutableSharedFlow<Screen> = MutableSharedFlow()
val navigationState: SharedFlow<Screen> = _navigationState
Copy code
// in fragment
lifecycleScope.launch {
viewModel.navigationState.collectLatest { route ->
is it correct?
i have to use collect or collectLatest or it's better transform flow in LiveData?
c
There's no problem. I believe migration from LiveData to Flow is a good choice. But if you don't have enough time nor if you feel useless(ex. You only build android or all the Api are simple) then, I think it's fine.
a