hunk.code_window:  * @see {@link mergeMapTo}
    *
    * @param {ObservableInput} innerObservable An Observable to replace each value from
    * the source Observable.
    * @return {Observable} An Observable that emits items from the given
    * `innerObservable` (and optionally transformed through `resultSelector`) every
    * time a value is emitted on the source Observable, and taking only the values
    * from the most recently projected inner Observable.
    * @method switchMapTo
    * @owner Observable
    */
   export function switchMapTo<T, I, R>(
  
hunk.labels: keep keep keep keep keep replace replace keep keep keep keep keep
hunk.after_edit:  * `innerObservable` (and optionally transformed through the deprecated `resultSelector`)
    * every time a value is emitted on the source Observable, and taking only the values
  
hunk.file_path: src/internal/operators/switchMapTo.ts
hunk.type: replace
file: // #docregion
  /* avoid */
  
  import { OnInit } from '@angular/core';
  import { Http, Response } from '@angular/http';
  
  import { Observable } from 'rxjs';
  import { catchError, finalize, map } from 'rxjs/operators';
  
  import { Hero } from '../shared/hero.model';
  
  const heroesUrl = 'http://angular.io';
  
  export class HeroListComponent implements OnInit {
    heroes: Hero[];
    constructor(private http: Http) {}
    getHeroes() {
      this.heroes = [];
      this.http.get(heroesUrl).pipe(
        map((response: Response) => <Hero[]>response.json().data),
        catchError(this.catchBadResponse),
        finalize(() => this.hideSpinner())
      ).subscribe((heroes: Hero[]) => this.heroes = heroes);
    }
    ngOnInit() {
      this.getHeroes();
    }
  
    private catchBadResponse(err: any, source: Observable<any>) {
      // log and handle the exception
      return new Observable();
    }
  
    private hideSpinner() {
      // hide the spinner
    }
  }
  