Closed chug2k closed 8 years ago
We have the beginning of an RxJava guide here as well. Maybe we should add a note to the event bus guide, that Otto is deprecated? RxAndroid is the way I think the world is moving even though there is this still somewhat maintained alternative.
cc @rogerhu
I looked at the approach with RxJava/RxAndroid (http://nerds.weddingpartyapp.com/tech/2014/12/24/implementing-an-event-bus-with-rxjava-rxbus/) and feel it's a step backwards. You have to do a bunch of instance checks on the bus and decide what to do.
EventBus 3.0 has gone the way of annotation libraries and seems to vastly have done better in the way of perf (https://github.com/greenrobot/EventBus/blob/master/COMPARISON.md). In fact it's far easier to use than Otto because it provides annotations for handling messages posted on a separate thread.
Update guides already to use EventBus library now. Take a look.
Great, thanks! I agree RXJava is heavier weight than a simple event bus mechanism.
can anybody share with me some good example of RxAndroid please?
http://reactivex.io/tutorials.html @mikolasw
The reference from Otto is at http://nerds.weddingpartyapp.com/tech/2014/12/24/implementing-an-event-bus-with-rxjava-rxbus/. It basically entails using a PublishSubject
object of a generic type and emitting the bus event from there. Any subscribers downstream need to decode and do an instanceof check.
@rogerhu …or use multiple PublishSubject
s. Which may violate the spirit of a "bus" but may also result in a cleaner and less confusing implementation, with no need for instanceOf
checks.
RxJava is best
https://github.com/codepath/android_guides/wiki/Communicating-with-an-Event-Bus recommends Otto, but according to https://github.com/square/otto, the project's been deprecated in favor of RXJava/RXAndroid.
Likely related to #109