I have two `ViewModel`s that are dependent on data...
# coroutines
m
I have two `ViewModel`s that are dependent on data from common class that exposes data with
StateFlow
. I would like to observe data changes but my concern is collecting that
StateFlow
. it never completes so how will it behave if I
collect
it from
ViewModel
? but using
flow.value
does not give me anything over having a property. what am I missing here?
n
collect
will end when you cancel the scope that launched its coroutine. If you only call
flow.value
and don't
collect
then there is no reason for you to use a
StateFlow
except maybe to allow collecting later.
🙏 1
👍 1