title: Is there a pipe operator that will run code before subscription is resolving? ex: http call
body: <p>I'm making HTTP calls and want to set a loading indicator before the HTTP call is made. At the moment I'm doing:</p>
  
  <pre><code>this.loadingIndicatorService.setLoadingIndicatorOn(true)
      this.cop.getunMappedTechnologyDetails().pipe(
        finalize(() =&gt; {
          this.loadingIndicatorService.setLoadingIndicatorOn(false);
        }),
      ).subscribe(
        res =&gt; {...}
  </code></pre>
  
  <p>But I would like to set the loadingindicator inside the pipe if possible, so that I can be sure it runs and so that I can easily copy/paste it in front of all my subscriptions. (I've looked in to AOP, but it seems to be unpractical in this particular case)</p>
  
  <p>tap doesn't work because it fetches first and then acts upon the result, but I'm showing it as visual for what I want to have:</p>
  
  <pre><code>this.cop.getunMappedTechnologyDetails().pipe(
        tap(() =&gt; this.loadingIndicatorService.setLoadingIndicatorOn(true)),
        finalize(() =&gt; {
          this.loadingIndicatorService.setLoadingIndicatorOn(false);
        }),
      ).subscribe(
        res =&gt; {...}
  </code></pre>
  
  <p>I might be looking into a generic function too, but for now I need a quick solution where I could paste in these pipes in front of my subscriptions.</p>
  
  <p>EDIT:
  I've tried Jan-Niklas Wortmann option with defer, but I get an error on .pipe:</p>
  
  <p>I then tried using it inside the pipe:</p>
  
  <pre><code>this.cop.getunMappedSafeDetails().pipe(
        defer(() =&gt; {
          this.loadingIndicatorService.setLoadingIndicatorOn(true);
          return this.cop.getunMappedSafeDetails();
        }),
        finalize(() =&gt; {
          this.loadingIndicatorService.setLoadingIndicatorOn(false);
        }),
      ).subscribe(...);
  </code></pre>
  
  <p>But I have error :</p>
  
  <pre><code>Argument of type 'Observable&lt;String[]&gt;' is not assignable to parameter of type 'OperatorFunction&lt;String[], {}&gt;'.
    Type 'Observable&lt;String[]&gt;' provides no match for the signature '(source: Observable&lt;String[]&gt;): Observable&lt;{}&gt;'.
  </code></pre>