Last active
November 17, 2015 12:26
-
-
Save talenguyen/eb17d6c118373c6914c6 to your computer and use it in GitHub Desktop.
EventBus implementation use RxJava
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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