title: Angular 6 Create an observable to check a variable for change
body: <p>I am using Angular 6 and I want to check a variable for changes and the stop or unsubscribe when the variable has a value.</p>
  
  <p>So I was thinking of an Observable:</p>
  
  <pre><code>myValue; // variable to be checked
  
  myObservable = Observable.timer(2000); // every 2 seconds
  
  myObservable.subscribe(); // start
  </code></pre>
  
  <p>Then keep checking myValue and if the value is not empty</p>
  
  <pre><code>myObservable.unsubscribe(); // stop
  </code></pre>
  
  <p>This is the idea anyway...</p>
  
  <p>How can I do this?</p>