angular observable cache
import { Injectable } from '@angular/core';import { Http, Response } from '@angular/http';import { Observable, ReplaySubject } from 'rxjs';@Injectable()export class CachedService { data$: Observable<Response> = this.replaySubject.asObservable(); private replaySubject= new ReplaySubject<Response>(1); constructor(private http: Http) { } fetch() { this.http.get(...).subscribe(data => this.replaySubject.next(data)); }}