codepath / android_guides

Extensive Open-Source Guides for Android Developers
guides.codepath.com
MIT License
28.3k stars 6.35k forks source link

Otto deprecated #151

Closed chug2k closed 8 years ago

chug2k commented 8 years ago

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

nesquena commented 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.

nesquena commented 8 years ago

cc @rogerhu

rogerhu commented 8 years ago

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.

rogerhu commented 8 years ago

Update guides already to use EventBus library now. Take a look.

nesquena commented 8 years ago

Great, thanks! I agree RXJava is heavier weight than a simple event bus mechanism.

mykola-tarchanyn commented 8 years ago

can anybody share with me some good example of RxAndroid please?

dionesxxx commented 8 years ago

http://reactivex.io/tutorials.html @mikolasw

rogerhu commented 8 years ago

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.

anaselhajjaji commented 8 years ago

@mikolasw https://github.com/anaselhajjaji/android-samples/tree/master/RxAndroidSample

RobLewis commented 7 years ago

@rogerhu …or use multiple PublishSubjects. 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.

mirzaadil commented 6 years ago

RxJava is best