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

dakinne

07/24/2019, 9:30 AM
I want to use a event bus in my project. I use kotlin and coroutines but I don't use Rx. Can you recommend me what event bus to use or a good approach?
g

gildor

07/24/2019, 9:38 AM
Opinion: Good event bus is no event bus
👍 5
glitch crab 5
r

ruialonso

07/24/2019, 9:39 AM
no event bus
r

rkeazor

07/24/2019, 9:41 AM
No event bus😂😂
People shouldnt be talking about eventbus in 2019😂😂
g

gildor

07/24/2019, 9:46 AM
Actual answer depends on your use case of course, maybe you could provide what you want to achieve with event bus
d

dakinne

07/24/2019, 10:07 AM
The app has a bottom navigation bar. One option start a new activity with a form for create products, and another option show a list of products. In the list of products I can tap on a product for see the detail. If I stay in a product detail and I tap on first option the createProductActivity is started. When the product is created I need to refresh de list of product. How can I do it? [I'm spanish, sorry for my english]
r

ruialonso

07/24/2019, 10:19 AM
your view can observe a Livedata of productList that is modified by CreateProductUseCase in a coroutine
👍 1
to avoid bifurcation on success/error your Livedata could be an Either of productList
r

rkeazor

07/24/2019, 10:22 AM
Yea observing a livedata object would work fine
g

gildor

07/24/2019, 10:22 AM
Or Flow
r

rkeazor

07/24/2019, 10:22 AM
lol
g

gildor

07/24/2019, 10:23 AM
Yes Robert, I thought about you when wrote my message 😅
😂 2
r

rkeazor

07/24/2019, 10:23 AM
The problem with EventBus, is that its one hard to understand the flow of control in the application. Two its weird to tests(if you have tests)
r

ruialonso

07/24/2019, 10:25 AM
event bus is not sequential, so you lost flow. Besides needed to much events for success and error
😂 1
r

rkeazor

07/24/2019, 10:26 AM
EventBus was good during a time when the Android Framework wasn't very friendly. But its been many years since than, and the ecosystem has grown.
Pow thank you @ruialonso thats what i've been trying to tell @gildor .Different usecases lol
r

ruialonso

07/24/2019, 10:27 AM
👍
d

dakinne

07/24/2019, 10:28 AM
Can I see a sample o a project in github about this solution?
All the samples you will ever need lol
later guys, going back to bed. got work in the morning.
d

dakinne

07/24/2019, 10:30 AM
Thanks a lot guys
306 Views