Created
April 14, 2016 08:30
-
-
Save yatatsu/3ddcc893cb72c6336f048527c98d89d8 to your computer and use it in GitHub Desktop.
This file contains 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
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