code: public static <T> Observable<T> toObservable(EventPublisher<T> eventPublisher) {
          PublishSubject<T> publishSubject = PublishSubject.create();
          Subject<T> serializedSubject = publishSubject.toSerialized();
          eventPublisher.onEvent(serializedSubject::onNext);
          return serializedSubject;
      }
docs: Converts the EventPublisher into an Observable.
  
  @param eventPublisher the event publisher
  @param <T> the type of the event
  @return the Observable