Subject based event bus (rxandroid-eventbus)

This is a long standing thing I meant to pull out of our app which has proven invaluable for us. It's just a thin wrapper around Rx subjects, but with an API that lends itself well for dependency injection.

Sample activity:
https://github.com/ReactiveX/RxAndroid/pull/60/files#diff-18

Sample service:
https://github.com/ReactiveX/RxAndroid/pull/60/files#diff-19
That method exists -- it's called `queue`. The subscribe method exists to
support the most likely case, which is observing on the main thread. This
was added intentionally because people constantly forgot to observeOn main
thread and would run into all sorts of visibility issues. That was
particularly tough to debug since unlike with normal observables there is
an additional layer of indirection.

I'm cool with removing subscribeImmediate though in favor of just
subscribing to the Subject directly. I believe we only do this in one or
two cases, so it was a corner case for us, hence the late addition and
awkward name...

I do believe in the value of the method that subscribes on the main thread
for you though. It makes the call site less verbose and more fool proof for
the 90% case.

Sorry I'm on my phone
On Nov 20, 2014 7:26 PM, "Jake Wharton" <notifications@github.com> wrote:

> In rxandroid-eventbus/src/main/java/rx/android/eventbus/EventBus.java:
>
> > +public interface EventBus {
> > +
> > +    /**
> > +     * Subscribes <code>observer</code> to <code>queue</code>.
> > +     * <p>
> > +     * This variant always delivers notifications on the Android main thread.
> > +     */
> > +    <T> Subscription subscribe(EventQueue<T> queue, Observer<T> observer);
> > +
> > +    /**
> > +     * Subscribes <code>observer</code> to <code>queue</code>.
> > +     * <p>
> > +     * Unlike {@link #subscribe(EventQueue, Observer)}, this variant delivers notifications
> > +     * on the same thread as the event source.
> > +     */
> > +    <T> Subscription subscribeImmediate(EventQueue<T> queue, Observer<T> observer);
>
> I don't see the utility in any of these methods. Why not just expose an
> Observable<T> so that I can do whatever I want? Instead we hide the
> interesting bits so I can no longer transform events, subscribe on whatever
> scheduler I want, etc.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/ReactiveX/RxAndroid/pull/60/files#r20666293>.
>