https://kotlinlang.org logo
#android
Title
# android
v

voben

11/28/2019, 5:47 PM
I’m trying to send data from an android service to an activity. I would usually do this with a broadcast receiver, but I was wondering if this was something I could use a Coroutine channel for and how would that work?
p

Paul Woitaschek

11/28/2019, 5:52 PM
You could create an event bus using private channel; exposing a flow and having suspend functions which send to the channel
c

codeslubber

11/28/2019, 7:03 PM
Or follow the examples they have of such things in the architecture patterns, using a
ViewModel
. As usual, 10 different ways to do it.
v

voben

11/28/2019, 7:37 PM
@codeslubber What examples? Could you provide the link?
m

Mohitmadaan27

12/01/2019, 9:58 AM
Try -Event Bus -Handler (send message)
v

voben

12/01/2019, 10:06 AM
Was looking for a solution based on Coroutine channels, but I figured it out based on Paul’s suggestion
2 Views