hello everyone, I want to know that to hold composables screens states in viewModel which one do I u...
z
hello everyone, I want to know that to hold composables screens states in viewModel which one do I use
SharedFlow
or
StateFlow
? cuurently I am using
SharedFlow
.
m
StateFlow
which you can then easily
.collectAsState()
in your composable functions.
z
Ok, thanks
SharedFlow can be collectAsState though, so what is major difference between them?
h
@Zaki Shaikh your composables always need to have a state. SharedFlow doesn't need an initial value but StateFlow does.
z
Yes and also it is easy to access last state by calling state.value, thank you