title: How to load files in parallel with rx-java?
body: <p>I am looking for a proper way to download multiple (image) files in parallel with rxjava.
  After all files have completed downloading, the subscriber should be notified.</p>
  
  <p>However the only way to do this I found is like this:</p>
  
  <pre><code>retrieveSlidesPlistObservable()
  
          .observeOn(AndroidSchedulers.mainThread())
          .subscribeOn(Schedulers.io())
  
          .flatMap(slidesPlist -&gt; {
  
              final ExecutorService executor = new ThreadPoolExecutor(4, 4, 1, TimeUnit.MINUTES, new LinkedBlockingQueue&lt;Runnable&gt;());
  
              String[] imagesUrls = slidesPlist.getImageUrls();
              Observable&lt;? extends String&gt;[] imgDownloadObservables = new Observable[imagesUrls.length];
              for (int i = 0; i &lt; imagesUrls.length; i++) {
                  imgDownloadObservables[i] = Observable.from(executor.submit(new DownloadResourceCallable(imagesUrls[i])));
              }
  
              return Observable.merge(imgDownloadObservables);
          })
  
          .subscribe(
                  onNext -&gt; {
                      log("onNext:" + onNext);
                  },
                  throwable -&gt; {
                      log("onError");
                  },
                  () -&gt; {
                      log("onComplete");
                  }
          );
  
  ...
  
  private static final class DownloadResourceCallable implements Callable&lt;String&gt; {
      private final String mUrl;
  
      public DownloadResourceCallable(final String url) {
          mUrl = url;
      }
  
      @Override
      public String call() throws Exception {
          log("downloading " + mUrl + "...");
          // simulate fetching data from remote service
          Thread.sleep(2000);
          return "success " + mUrl;
      }
  }
  </code></pre>
  
  <p>But filling an <code>Observable&lt;? extends String&gt;[]</code> array like that just doesn’t feel right. </p>
  
  <ol>
  <li><p>Is there a better -more rx-ish way to achieve this?</p></li>
  <li><p>How would one publish the current progress like in an android AsyncTask with onProgressUpdate() ?</p></li>
  </ol>