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

orafaaraujo

12/02/2019, 10:29 AM
Hello everyone, Is it possible to hear a
BroadcastChannel
out of a
Coroutine
?
I would not like to use
asFlows()
to need to add a Coroutines, scope etc..
p

Paul Woitaschek

12/02/2019, 10:44 AM
What do you want to achieve?
o

orafaaraujo

12/02/2019, 10:46 AM
I'm trying to replace a
PublishSubject
But I don't need to move it to background
I'm sharing strings from a search bar from a
Activity
to two
Fragments
under tabs, using shared view model
Then, each fragment read this value and send it to their own ViewModels to handle this search
p

Paul Woitaschek

12/02/2019, 10:49 AM
Then use the lifecycleScope of the fragment to collect the events. Coroutines don't make sense without scopes
o

orafaaraujo

12/02/2019, 10:50 AM
yeah, If I could, I would like to avoid adding more complexity into my fragments otherwise, I'll do that
p

Paul Woitaschek

12/02/2019, 10:50 AM
You could use a regular listener
Copy code
typealias SearchListener = (String) -> Unit
o

orafaaraujo

12/02/2019, 10:53 AM
yes, would be simpler
Thank you 🙂
2 Views