Skip to content

Instantly share code, notes, and snippets.

@talenguyen
Last active November 17, 2015 12:26
Show Gist options
  • Save talenguyen/eb17d6c118373c6914c6 to your computer and use it in GitHub Desktop.
Save talenguyen/eb17d6c118373c6914c6 to your computer and use it in GitHub Desktop.
EventBus implementation use RxJava
import rx.Subscription;
import rx.functions.Action1;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
public class RxBus {
private final Subject<Object, Object> bus = new SerializedSubject<Object, Object>(PublishSubject.create());
public void send(Object o) {
bus.onNext(o);
}
public Observable<Object> toObservable() {
return bus;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment