title: RXJava - Split and Combine an Observable
body: <p>I am new to RxJava and need some help/guidance on how to do the following:</p>
  
  <blockquote>
    <p>I need to get two values from an Observable </p>
    
    <ul>
    <li>a String</li>
    <li>a List&lt;.ObjectA></li>
    </ul>
    
    <p>I then need to apply two different filters() on this list and then
    finally combine all of them(String, FilteredListA, FilteredListB) into
    a single observable.</p>
  </blockquote>
  
  <p><strong>Is there a single chained call I can use???(need example of groupBy maybe)</strong></p>
  
  <p>Below is the sample code that is doing the same. </p>
  
  <pre><code>MasterObject = String, List&lt;.ObjectA&gt;
  
   Observable&lt;ReturnObject&gt; getReturnObject() { 
  
          Observable&lt;MasterObject&gt; masterObjectObservable = getMasterObjectObservable();
  
  
          Observable&lt;String&gt; myStringbservable = masterObjectObservable.map(new Func1&lt;MasterObject, String&gt;() {
              @Override
              public String call(MasterObject masterObject) {
                  return masterObject.getString();
              }
          });
  
          return  masterObjectObservable.flatMap(new Func1&lt;MasterObject, Observable&lt;ObjectA&gt;&gt;() {
              @Override
              public Observable&lt;MasterObject&gt; call(MasterObject masterObject) {
                  return Observable.from(masterObject.getList());
              }
          }).filter(new Func1&lt;ObjectA, Boolean&gt;() {
              @Override
              public Boolean call(ObjectA objectA) {
                  return objectA.isTrue();
              }
          }).toList().concatWith(getSecondList(masterObjectObservable)).zipWith(publicKeyObservable, new Func2&lt;List&lt;ObjectA&gt;, String, ReturnObject&gt;() {
              @Override
              public ReturnObject call(List&lt;ObjectA&gt; listObjectA, String string) {
                  return new ReturnObject(string, listObject);
              }
          });
  }
  
  
  private Observable&lt;List&lt;ObjectA&gt;&gt; getSecondList(Observable&lt;MasterObject&gt; masterObject) {
     return masterObject.flatMap(new Func1&lt;MasterObject, Observable&lt;ObjectA&gt;&gt;() {
          @Override
          public Observable&lt;ObjectA&gt; call(MasterObject masterObject) {
              return Observable.from(masterObject.getList());
          }
      }).filter(new Func1&lt;ObjectA, Boolean&gt;() {
          @Override
          public Boolean call(ObjectA objectA) {
              return objectA.isCondition();
          }
      }).toSortedList(new Func2&lt;ObjectA, ObjectA, Integer&gt;() {
          @Override
          public Integer call(ObjectA a, ObjectA b) {
              return a.getCondition()
                      .compareTo(b.getCondition());
          }
      });
  
  }
  </code></pre>