Simple way to get the current value of a BehaviorSubject with rxjs5
<p>Previously in <strong>rxjs4</strong> there was a method in the BehaviorSubject called:
<code>getValue()</code> (<a href="https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/subjects/behaviorsubject.md#rxbehaviorsubjectprototypegetvalue" rel="noreferrer">doc here</a>).</p>
<p>This method does not exist anymore in <strong>rxjs5</strong>.</p>
<p>So the only solution that I found to get the value of a BehaviorSubject was:</p>
<pre><code>let value;
myBehaviorSubject.take(1).subscribe( (e) =&gt; value = e );
</code></pre>
<p>This code runs synchronously (I do not exactly understand why, but it does ...) and gets the value. It works, but it's not as clean as it could be if <code>getValue()</code> was present:</p>
<pre><code>let value = myBehaviorSubject.getValue();
</code></pre>
<p>Why <code>getValue()</code> was removed in <strong>rxjs5</strong> and what's the cleanest solution to this problem?</p>