Android Open Source - Android-RxJava Rx Bus






From Project

Back to project page Android-RxJava.

License

The source code is released under:

Apache License

If you think the Android project Android-RxJava listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.morihacky.android.rxjava.rxbus;
/*www . j  a  v a 2 s.c  o m*/
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;

/**
 * courtesy: https://gist.github.com/benjchristensen/04eef9ca0851f3a5d7bf
 */
public class RxBus {

  //private final PublishSubject<Object> _bus = PublishSubject.create();

  // If multiple threads are going to emit events to this
  // then it must be made thread-safe like this instead
  private final Subject<Object, Object> _bus = new SerializedSubject<>(PublishSubject.create());

  public void send(Object o) {
    _bus.onNext(o);
  }

  public Observable<Object> toObserverable() {
    return _bus;
  }

  public boolean hasObservers() {
    return _bus.hasObservers();
  }
}




Java Source Code List

com.morihacky.android.rxjava.BufferDemoFragment.java
com.morihacky.android.rxjava.ConcurrencyWithSchedulersDemoFragment.java
com.morihacky.android.rxjava.DemoTimeoutFragment.java
com.morihacky.android.rxjava.DoubleBindingTextViewFragment.java
com.morihacky.android.rxjava.MainActivity.java
com.morihacky.android.rxjava.MainFragment.java
com.morihacky.android.rxjava.PollingFragment.java
com.morihacky.android.rxjava.RetrofitFragment.java
com.morihacky.android.rxjava.SubjectDebounceSearchEmitterFragment.java
com.morihacky.android.rxjava.app.ApplicationTest.java
com.morihacky.android.rxjava.retrofit.Contributor.java
com.morihacky.android.rxjava.retrofit.GithubApi.java
com.morihacky.android.rxjava.retrofit.User.java
com.morihacky.android.rxjava.rxbus.RxBusDemoFragment.java
com.morihacky.android.rxjava.rxbus.RxBusDemo_Bottom1Fragment.java
com.morihacky.android.rxjava.rxbus.RxBusDemo_Bottom2Fragment.java
com.morihacky.android.rxjava.rxbus.RxBusDemo_Bottom3Fragment.java
com.morihacky.android.rxjava.rxbus.RxBusDemo_TopFragment.java
com.morihacky.android.rxjava.rxbus.RxBus.java