Android Rxjava subscribe to a variable change : <p>I am learning Observer pattern, I want my observable to keep track of a certain variable when it changes it's value and do some operations, I've done something like :</p>

<pre><code>public class Test extends MyChildActivity {

   private int VARIABLE_TO_OBSERVE = 0;

   Observable&lt;Integer&gt; mObservable = Observable.just(VARIABLE_TO_OBSERVE);  

   protected void onCreate() {/*onCreate method*/
       super();
       setContentView();
       method();
       changeVariable();
   }

   public void changeVariable() {
       VARIABLE_TO_OBSERVE = 1;
   }

   public void method() {
       mObservable.map(value -&gt; {
            if (value == 1) doMethod2();
            return String.valueOf(value);
       }).subScribe(string -&gt; System.out.println(string));
   }

   public void doMethod2() {/*Do additional operations*/}

}
</code></pre>

<p>But doMethod2() doesn't get called</p>
