title: How can I use the same observable with multiple mappings?
body: <p>My code has a <code>Subject</code> which, when new values are added triggers a HTTP request which returns an <code>Observable</code>.</p>
  
  <p>I want to process this data in two different ways (using the same data) and use the resulting <code>Observables</code> stored in <code>group</code> and <code>times</code> as values to put in <code>ngFor</code> using the <code>async</code> pipe.</p>
  
  <p>While this does work, the HTTP requests are sent multiple times - I only want them to be sent once for each subscription.</p>
  
  <p>Below is a minimal example.</p>
  
  <pre><code>import { Component, OnInit } from "@angular/core";
  import { Observable } from "rxjs/Observable";
  import { Subject } from "rxjs/Subject";
  
  import { ExampleService } from "../example.service";
  
  import "rxjs/add/operator/switchMap";
  
  @Component({
    templateUrl: "./example.component.html",
    styleUrls: ["./example.component.scss"]
  })
  export class ExampleComponent implements OnInit {
  
    constructor(
      private exampleService: ExampleService
    ) { }
  
    ngOnInit() {
  
      var selections = new Subject&lt;string&gt;();
  
      var appointments = selections
        // exampleService.getData returns an HTTP observable.
        .switchMap(date =&gt; this.exampleService.getData(date));
  
      var group = appointments
        .map(data =&gt; this.process(data));
  
      var times = appointments
        .map(data =&gt; this.calculateTimes(data));
  
      // Calling subscribe each time sends the HTTP request multiple
      // times - I only want it to be send once for both of them: they
      // can share the data!!
      group.subscribe();
      times.subscribe();
  
      // selections.next(someData) is called periodically from some
      // omitted code.
    }
  
    processExample(data: string[]) {
      /*
       * Some processing code.
      */
  
      return data;
    }
  
    calculateTimes(data: string[]) {
      /*
       * Some processing code.
      */
  
      return data;
    }
  }
  </code></pre>
  
  <p>What is the best way to achieve this?</p>