title: How to model class that extends Observable to access state information: Cannot refer to an instance field while explicitly invoking a constructor
body: <p>I would like to model an industrial system which consists of a conveyor belt that has a sensor to detect when an object reaches certain position using RxJava.</p>
  
  <p>To simulate the sensor I have a fake class that should receives and object position and increments it with time until it reached the supposed sensor position. Then it would notify it's observers (the conveyor belt):</p>
  
  <pre><code>public class FakeBeltPositionSensor extends Observable&lt;Signal&gt;{
  
      private double objectPosition;
      protected Double sensorPosition;
  
      public FakeBeltPositionSensor(Double sensorPosition) {
          super( (s) -&gt; {
              Thread.sleep(500);
              objectPosition += 1;
              if(objectPosition == sensorPosition){
                  s.onNext(new Signal(Signal.Type.SENSOR_REACHED));
                  s.onCompleted();
              }
          });
      }
  
      public Double getSensorPosition() {
          return sensorPosition;
      }
  
      public void setObjectPosition(double objectPosition){
          this.objectPosition = objectPosition;
      }
  }
  </code></pre>
  
  <p>The problem I am facing is that obviously I can't access <code>double objectPosition</code> in the class constructor: <code>Cannot refer to an instance field objectPosition while explicitly invoking a constructor</code>.</p>
  
  <p>Since extending Observable forces you to implement the Observable->subscriber login in the constructor, how would you model this scenario? </p>
  
  <p>The idea is that <code>FakeBeltPositionSensor</code> would run continuosly and be able to use <code>setObjectPosition</code> to update the object position.</p>