title: How to return or use list as a response of multiple requests using retrofit2/rxjava2?
body: <p>I need a list of articles as a response that I set in my adapter. When the code is like below, nothing happens. The program does not go in place 1. or 2.
  On the other hand, when I uncomment the line that makes the method adynchronous, I have correct response, at 1. place and 2. place, I can display the list of responses. However, I can't do anything with it, neither copy nor return nor set in adapter there.
  What can I do to get a list of articles? Help please :(</p>
  <p>Here is the interface:</p>
  <pre><code>@GET(&quot;articles/{id}&quot;)
  Observable&lt;Articles&gt; getArticle1(@Path(&quot;id&quot;) int id);
  </code></pre>
  <p>and here is the function:</p>
  <pre><code>private void getListArticles(List&lt;Integer&gt; l) {
      Retrofit retrofit = new Retrofit.Builder()
              .baseUrl(baseURL)
              .addConverterFactory(GsonConverterFactory.create())
              .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
              .build();
      final List&lt;Articles&gt; ar = new ArrayList&lt;&gt;();
      ApiInterface apiInterface = retrofit.create(ApiInterface.class);
  
      List&lt;Observable&lt;?&gt;&gt; requests = new ArrayList&lt;&gt;();
      for(int id: l){
          requests.add(apiInterface.getArticle1(id));
      }
  
      Observable.zip(requests, new Function&lt;Object[], List&lt;Articles&gt;&gt;() {
                  @Override
                  public List&lt;Articles&gt; apply(@NonNull Object[] objects) throws Exception {
                      // PLACE 1.
                      List&lt;Articles&gt; articlesArrayList = new ArrayList&lt;&gt;();
                      for (Object response : objects) {
                          articlesArrayList.add((Articles) response);
                      }
                      
                      System.out.println(articlesArrayList );
                      System.out.println(&quot;hello&quot;);
  
                      return articlesArrayList;
                  }
              })
              //.subscribeOn(Schedulers.io())  //async
              .observeOn(Schedulers.newThread())
              .subscribe(
                      new Consumer&lt;List&lt;Articles&gt;&gt;() {
                          @Override
                          public void accept(List&lt;Articles&gt; articlesList) throws Exception {
                              // PLACE 2.
                              ar.addAll(articlesList);
                              // set adapter
                              //recycleView.setAdapter(new Adapter (articlesList, getApplicationContext ()));
                              System.out.println(articlesArrayList );
                              System.out.println(&quot;hello&quot;);
  
                          }
                      },
                      new Consumer&lt;Throwable&gt;() {
                          @Override
                          public void accept(Throwable e) throws Exception {
  
                          }
                      }
              );
     
      System.out.println(ar);
      //return ar;
  
  }
  </code></pre>