Sibling interactions with subjects

The main reason for components to interact is to send or receive updates to data either provided by the user or received from the server. In Angular, your services expose RxJS.Observable endpoints, which are data-streams that your components can subscribe to. RxJS.Observer compliments RxJS.Observable as a consumer of events emitted by Observable. RxJS.Subject brings the two sets of functionalities together, in an easy to work with object. You can essentially describe a stream that belongs to a particular set of data, such as the current weather data that is being displayed, with subjects:

src/app/weather/weather.service.tsimport { Subject } from 'rxjs'...export class WeatherService implements IWeatherService ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.