class RxEventSources {

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

      @Nonnull
      @Override
      public com.spotify.mobius.disposables.Disposable subscribe(
          com.spotify.mobius.functions.Consumer<E> eventConsumer) {
        final Disposable disposable =
            eventSource.subscribe(
                new Consumer<E>() {
                  @Override
                  public void accept(E value) throws Throwable {
                    eventConsumer.accept(value);
                  }
                },
                new Consumer<Throwable>() {
                  @Override
                  public void accept(Throwable error) throws Throwable {
                    RxJavaPlugins.onError(error);
                  }
                });
        return new com.spotify.mobius.disposables.Disposable() {
          @Override
          public void dispose() {
            disposable.dispose();
          }
        };
      }
    };
  }

  private  RxEventSources();

}