title: How to clean rxjs cache with standard method
body: <p>I have a service which is caching data from the server. But I need clean cache every 10 seconds after the last call of <code>getView()</code>.</p>
  
  <pre><code>import {shareReplay} from 'rxjs/operators';
  
  
  cache$: Observable&lt;any&gt;;
  getView() {
    if (!this.organizationViewCache$) {
      this.cache$ = this.baseApiDependenciesService.http.post(
        `my-api`, {}, this.getHeaders()
      ).pipe(
        shareReplay(1),
        catchError(this.handleError)
      );
    }
    return this.organizationViewCache$;
  }
  </code></pre>
  
  <p>Perhaps here's good <code>const timer$ = timer(0, 10000);</code> from <code>{timer} from 'rxjs/observable/timer';</code> but I can't figure out how to:</p>
  
  <ol>
  <li>Connect <code>timer.pipe()</code> and <code>shareReplay(1)</code>, bacause <code>shareReplay(1)</code> already inside <code>http.post.pipe</code>?</li>
  <li>Clean cache <strong>not</strong> every 10 seconds but 10 seconds after the last call of <code>getView()</code> method. (If this possible, but not strong required)</li>
  </ol>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I find the solution which does similar behavior but I need do the same but with <code>RX/JS</code> tools:</p>
  
  <pre><code>getView() {
    if (!this.organizationViewCache$) {
      this.cache$ = this.baseApiDependenciesService.http.post(
        `my-api`, {}, this.getHeaders()
      ).pipe(
        shareReplay(1),
        catchError(this.handleError)
      );
  
      setTimeout(() =&gt; {
        this.cache$ = null;
      }, 10000)
    }
    return this.organizationViewCache$;
  }
  </code></pre>