class RxEventSources {

  @SafeVarargs
  public static <E> EventSource<E> fromObservables(ObservableSource<E>... sources) {
    final Observable<E> eventSource = Observable.mergeArray(sources);

    return new EventSource<E>() {
      @Nonnull
      @Override
      public Disposable subscribe(final Consumer<E> eventConsumer) {
        final io.reactivex.disposables.Disposable subscription =
            eventSource.subscribe(
                new io.reactivex.functions.Consumer<E>() {
                  @Override
                  public void accept(E e) throws Exception {
                    eventConsumer.accept(e);
                  }
                },
                new io.reactivex.functions.Consumer<Throwable>() {
                  @Override
                  public void accept(Throwable e) throws Exception {
                    RxJavaPlugins.onError(e);
                  }
                });

        return new Disposable() {
          @Override
          public void dispose() {
            subscription.dispose();
          }
        };
      }
    };
  }

  private  RxEventSources();

}