title: RxJS takeWhile but include the last value
body: <p>I have a RxJS5 pipeline looks like this</p>
  
  <pre><code>Rx.Observable.from([2, 3, 4, 5, 6])
    .takeWhile((v) =&gt; { v !== 4 })
  </code></pre>
  
  <p>I want to keep the subscription until I see 4, but I want to last element 4 also to be included in the result. So the example above should be</p>
  
  <pre><code>2, 3, 4
  </code></pre>
  
  <p>However, according to <a href="http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-takeWhile" rel="noreferrer">official document</a>, <code>takeWhile</code> operator is not inclusive. Which means when it encounters the element which doesn't match predicate we gave, it completes the stream immediately without the last element. As a result, the above code will actually output</p>
  
  <pre><code>2, 3
  </code></pre>
  
  <p>So my question is, what's the easiest way I can achieve <code>takeWhile</code> but also emit the last element with RxJS?</p>