Observable Blog Posts

Exchange data between components using service

Expected Behaviour: using Service to exchange data between components.
Observables open up a continuous channel of communication in which multiple values of data can be emitted over time.
BehaviourSubject holds the data that needs to shared with other components. I want to define filterType behaviour subject as boolean and set default value null to filterType. Components subscribe to filterObservable which will simply return BehaviourSubject value.
Declare  function to set value to BehaviourSubject.
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs'

0 Likes 277 Views