Otto is now deprecated. From the deprecation notice:
|apps/android/wikipedia : master||Rx: Remove Otto event bus!|
Hi @Dbrant , I went through the code. Some observations/questions below (Correct me if I am wrong anywhere) :
- We emit the events only on the main thread (ref: ThreadSafeBus class ). I am assuming we did this because of a self-defined contract which states that
- we are using event bus only for consuming events that require change in the ui.
- consumers should not do any intensive-work which could have been done on a background thread.
So, this is sort of a single pipeline. If there are multiple events at the same time, they would be emitted sequentially.
We can mimic this kind of single pipeline using Rx as described in the approach here. The baseline here is that we are using a
single observable for all the events
and therefore while consuming the events, we'll have to check specifically if this is the event we want to consume, similar to the code here.
While I don't like this style, this exactly mimics our current state and can be done as a first step.
The second solution is multiple pipeline model in which we'll basically create
one observable per event.
In this approach, we'll be transforming each of our *Event class into *ObservableEvent class.
I find the second approach to be more modular and testable.
Let me know what you think.
@yashasvi For the sake of simplicity, let's proceed with the single pipeline approach for now, and then evaluate whether expanding to multiple pipelines will be worth the effort.
One other thing I'd like to monitor is the increase in size that this will cause for our APK, as well as the increase in method count. Last time I checked, we were getting rather close to the dex limit, and I'd like to know how much closer this will push it.
minify was not enabled at that time. After rebasing, I noticed that we have enabled minifying for debug builds as well. Multidex is not needed now.
Here's the dex method count for a dev debug build:
After including rx: 48773