title: How to tap an observable for only the first emitted value
body: <p>I'd like to tap an observable so that I can execute a method when the first value of the observable emits. I'd like to do this so as to switch on or off a loading state in the UI:</p>
  <h2>My current method</h2>
  <pre><code>// Current .create observable
  public create = (entry: EntryPatch): Observable&lt;Entry&gt; =&gt;
    this.http.post&lt;NodeResponse&lt;Entry&gt;&gt;(this.serviceEndpoint, entry).pipe(
      map((response: NodeResponse&lt;Entry&gt;) =&gt;
        upsertNode&lt;Entry&gt;(response.data, this.entriesStore)))
  </code></pre>
  <h3>and what I'd like to be able to do with it</h3>
  <pre><code>public create = (entry: EntryPatch): Observable&lt;Entry&gt; =&gt;
    this.http.post&lt;NodeResponse&lt;Entry&gt;&gt;(this.serviceEndpoint, entry).pipe(
      tapFirst(() =&gt; this.datastore.loading = true),  // ⬅️ pseudocode
      map((response: NodeResponse&lt;Entry&gt;) =&gt;
        upsertNode&lt;Entry&gt;(response.data, this.entriesStore)),
      finalise(() =&gt; this.datastore.loading = false)) // ⬅️ switch off loading indicator
  </code></pre>
  <p>What would be the best way to achieve the <code>.tapFirst</code> operator (since it doesn't actually exist)?</p>
  <h2>Edit</h2>
  <p>As @Lesiak pointed out below, the structure I've proposed above actually starts the loading indicator <em>after</em> the response returns from the server which was not my intention. Hoewver even thought the original question was wrong I'm going to leae it up because the answers that have been posted are still really helpful and tackle both the requests that were implict in this question</p>
  <p>a) how to wrap the <em>whole</em> observable
  b) how to detect the first emission</p>