what’s the difference between applying `conflate` ...
# coroutines
k
what’s the difference between applying
conflate
on
Flow<T>
and using
StateFlow<T>
? Also, why can’t I just get a
StateFlow
when I use
map
on existing
StateFlow
?
s
Because map is already defined on a Flow and there it returns another Flow. A StateFlow is Flow, and since we don't want to change the api of Flow, that means that map on a StateFlow must return a Flow as well. You can create an extension method called something like mapWithState on a StateFlow to do what you want.
z
Roman explained why
map
on
StateFlow
doesn’t make sense here
k
I do have the exact same use case you mentioned in the First comment there. Is there any problem with the approach you shared ? IE,
state.map{ }.stateIn(scope)
?
z
No problem with it, as long as you have a scope