How to implement behavior subject using service in Angular 8
I’m going to show you a simple way: @Injectable() export class ProfileService { private profileObs$: BehaviorSubject<Profile> = new BehaviorSubject(null); getProfileObs(): Observable<Profile> { return this.profileObs$.asObservable(); } setProfileObs(profile: Profile) { this.profileObs$.next(profile); } } Now when you update something anywhere in the application, you can set that change by the ProfileService and each subscriber is receiving the change. … Read more