Guest User

Untitled

a guest
Oct 19th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. public final class RxBus {
  2.  
  3. private static RxBus instance;
  4.  
  5. private RxBus() {
  6. }
  7.  
  8. public static synchronized RxBus getInstance() {
  9. if (instance == null) {
  10. instance = new RxBus();
  11. }
  12. return instance;
  13. }
  14.  
  15. private final PublishProcessor<Object> bus = PublishProcessor.create();
  16.  
  17. public void send(final Object event) {
  18. bus.onNext(event);
  19. }
  20.  
  21. public <T> Flowable<T> event(Class<T> classz) {
  22. return bus.ofType(classz);
  23. }
  24.  
  25. public Flowable<Object> toObservable() {
  26. return bus;
  27. }
  28. }
Add Comment
Please, Sign In to add comment