RxJS 5, converting an observable to a BehaviorSubject(?) : <p>I have a parent observable that, once it has a subscriber, will do a lookup and emit a single value, then complete.</p>

<p>I'd like to convert that into an observable (or behavior subject or whatever works) that does the following: once it has at least one subscriber, it gets the result from the parent observable (once). Then it emits that value to all of its subscribers, and also emits that single value to all future subscribers, when they subscribe. It should continue with this behavior even if its subscriber count drops to zero.</p>

<p>It seems like this should be easy. Here is what didn't work:</p>

<pre><code>theValue$: Observable&lt;boolean&gt; = parent$
.take(1)
.share()
</code></pre>

<p>Other things that didn't work: <code>publishReplay()</code>, <code>publish()</code>. Something that worked better:</p>

<pre><code>theValue$ = new BehaviorSubject&lt;boolean&gt;(false);

parent$
.take(1)
.subscribe( value =&gt; theValue$.next(value));
</code></pre>

<p>There is a problem with this approach, though: <code>parent$</code> is subscribed to before <code>theValue$</code> gets its first subscriber.</p>

<p>Is there a better way to handle this?</p>
