Wednesday, April 5, 2017

use a .do with Observable

act(url: string): Observable<Whatever> {
   return this.http.get(url)
      .map((response: Response) => <Whatever>response.json())
      .do(d => this.transformationOfStuff(<Whatever>d))
      .catch(this.handleError);
}
 
private transformationOfStuff(item: Whatever) {
   if (item) {
      item.taco = Taco.Breakfast;
   }
}

No comments:

Post a Comment