Created
April 22, 2015 20:46
-
-
Save akarnokd/c216fe638e69f9cf9187 to your computer and use it in GitHub Desktop.
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 java.util.*; | |
import rx.*; | |
import rx.subjects.*; | |
public class RxEventBus<T> { | |
private final Subject<Notification<T>, Notification<T>> subject; | |
public RxEventBus() { | |
subject = PublishSubject.<Notification<T>>create().toSerialized(); | |
} | |
public void post(T value) { | |
subject.onNext(Notification.createOnNext(value)); | |
} | |
public void postError(Throwable e) { | |
subject.onNext(Notification.createOnError(e)); | |
} | |
public Observable<Notification<T>> observe() { | |
return subject; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment