Implementing Reactive transformations

To avoid future mistakes in returning the unintended type of data from your service, you need to update the getCurrentWeather function to define the return type to be Observable<ICurrentWeather> and import the Observable type, as shown:

src/app/weather/weather.service.tsimport { Observable } from 'rxjs'import { ICurrentWeather } from '../interfaces'...
export class WeatherService {  ...  getCurrentWeather(city: string, country: string): Observable<ICurrentWeather> {  }  ...}

Now, VS Code will let you know that Type Observable<ICurrentWeatherData> is not assignable to type Observable<ICurrentWeather>:

  1. Write a transformation function named transformToICurrentWeather that can convert ICurrentWeatherData to  ...

Get Angular 6 for Enterprise-Ready Web Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.