Skip to content

Instantly share code, notes, and snippets.

@yatatsu
Created April 14, 2016 08:30
Show Gist options
  • Save yatatsu/3ddcc893cb72c6336f048527c98d89d8 to your computer and use it in GitHub Desktop.
Save yatatsu/3ddcc893cb72c6336f048527c98d89d8 to your computer and use it in GitHub Desktop.
public enum DialogEventBus {
OK,
CANCEL,
CLOSE,
;
private final SerializedSubject<String, String> bus;
DialogEventBus() {
bus = new SerializedSubject<>(PublishSubject.create());
}
public void post(String tag) {
bus.onNext(tag);
}
public Observable<String> toObservable(String tag) {
return bus.filter(s -> TextUtils.equals(s, tag));
}
public boolean hasObservers() {
return bus.hasObservers();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment