title: How can I get the single latest value from an infinite RxJs stream that is not the initial value?
body: <h3>The concept</h3>
  
  <p>This is a mocked angular2 project.</p>
  
  <p>When consuming the observable stream from the redux store I tried to filter first and then take/takeLast/last the latest value. 
  After that I want to resolve the promise when the stream completes but it does not when using takeLast operator.</p>
  
  <p>So the question is: <strong>What operator setup can I use to get the latest value from the stream</strong>?</p>
  
  <h3>The setup</h3>
  
  <p>I simplified my Angular 2 setup to this gist of RxJs usage.</p>
  
  <ul>
  <li>source observable is managed by redux library and is not completed</li>
  <li>service is providing some logic to retrieve the latest value from the stream</li>
  <li>component is consuming value promise style</li>
  </ul>
  
  <p>Here is a working example: <a href="https://fiddle.jshell.net/markus_falk/an41z6g9/" rel="noreferrer">https://fiddle.jshell.net/markus_falk/an41z6g9/</a></p>
  
  <p>The redux store mock:</p>
  
  <pre><code>var latestTime$ = new Rx.Subject();
  setInterval(function(){
       latestTime$.onNext(Date.now()); 
  }, 2000);
  </code></pre>
  
  <p>The service injectable mock:</p>
  
  <pre><code>var timeStore = null;
  var getLatestTime = function() {
  
    return new Promise((resolve, reject) =&gt; {
  
       latestTime$
  
       /* 
          filter out 'null' for when the button is clicked
          before the store updates the first time
        */
       .filter(function(x) {
          console.log('filter: ', x);
          return x === typeof('number');
       })
  
       // try to end to stream by taking the last from the stream ?!?!?!?
       .takeLast(1)
  
       // handle promise
       .subscribe(
  
         function (x) {
           console.log('Next: ' + x);
           // store latest stream value
           timeStore = x;
         },
         function (err) {
           console.log('Error: ' + err);
           reject(err)
         },
         function () {
           console.log('Completed');
           // pass on latest value of endless when stream completes 
           resolve(timeStore);
         }
  
      );
  
    });
  
  };
  </code></pre>
  
  <p>And a consuming mock component:</p>
  
  <pre><code>document.querySelector("#foo").addEventListener("click", function(event) {
  
    var time = getLatestTime();
  
    time.then((latestTime) =&gt; {
      console.log('latestTime: ', latestTime);
    });
  
    time.catch((err) =&gt; {
      console.log('oh oh: ', err);
    });
  
  }, false);
  </code></pre>