title: RxJava : How to send some additional info to subscriber
body: <p>I have created a simple method, which will send message ( as Object ) to given subject. At other end subscriber will consume the object.</p>
  
  <p>Am going to use same subject for multiple consumers, hence while sending message want to send some additional info i.e. 200, 300. So consumer can filter out un-relevant messages. But somehow not able to figure out how to do that.</p>
  
  <p>Additional info (int parameter)  can be handled at <code>postToSubject</code> method and at <code>action1</code> but not sure how to place it here <code>subject.onNext(object)</code> </p>
  
  <p>Please suggest if you can think any solution. </p>
  
  <pre><code>public void postToSubject(Object object, Subject subject) {
      Observable&lt;Object&gt; observable = Observable.create(new Observable.OnSubscribe&lt;Object&gt;() {
          @Override
          public void call(Subscriber&lt;? super Object&gt; subscriber) {
              subscriber.onNext(object);
              subscriber.onCompleted();
          }
      });
      observable.subscribe(new Action1() {
          @Override
          public void call(Object object) {
              subject.onNext(object);
          }
      });
  }
  </code></pre>
  
  <p>Above method is called as below ( from an Android Activity, objective is to send item to subject. Subject will be returned by second argument in the method )</p>
  
  <p><a href="https://i.stack.imgur.com/ecIJY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ecIJY.png" alt="Method call"></a></p>
  
  <p>At another Android Component Class ( inherited from Linear Layout ) , this message will be consumed as below. If I can get additional info i.e. 200, 300 , I will filter out and put onNext() inside it. This is the way I can think of a solution, however a RxJava expert may give a good solution. </p>
  
  <p><a href="https://i.stack.imgur.com/WDkiU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WDkiU.png" alt="consume message "></a> </p>
  
  <p><strong>Answer :</strong></p>
  
  <p>Additional Info passed through onNext() as below, subscriber will check using <code>if (object instanceof Integer)</code> and put the logic to fetch the next value returned by next onNext()</p>
  
  <p><a href="https://i.stack.imgur.com/07ZdV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/07ZdV.png" alt="Result "></a></p>