Skip to content

Instantly share code, notes, and snippets.

@akarnokd
Created April 22, 2015 20:46
Show Gist options
  • Save akarnokd/c216fe638e69f9cf9187 to your computer and use it in GitHub Desktop.
Save akarnokd/c216fe638e69f9cf9187 to your computer and use it in GitHub Desktop.
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