https://kotlinlang.org logo
#coroutines
Title
# coroutines
d

dave08

02/06/2020, 5:25 PM
If I have a conflated
BroadcastChannel
and I send something before using
asFlow()
on it, will I receive what was sent?
z

zak.taccardi

02/06/2020, 5:29 PM
yes, the
ConflatedBroadcastChannel<T>
will replay emissions of
T
on initial subscription, even if you convert it to a
Flow<T>
The
ConflatedBroadcastChannel<T>
should be stored in your
ViewModel
to survive config changes
d

dave08

02/06/2020, 5:30 PM
It's stored in the
Application
since the download is being done from a
Service
, but for some reason, we're not receiving the latest status...
z

zak.taccardi

02/06/2020, 5:38 PM
make sure that you are subscribing to the same
ConflatedBroadcastChannel<T>
instance each time?
d

dave08

02/06/2020, 5:45 PM
We are... the channel is a singleton in our DI and the
asFlow()
is run on it in a factory (to get a new instance every time it's injected).
2 Views