I am using RxJs Behaviour subjects in following manner as below.
=> Made a common service for all behaviour subjects like sample code below
@Injectable()
export class ProjectJobSelectionService {
public postTypeSubject = new BehaviorSubject(PostType.Project);
public selectedProjectSubject = new BehaviorSubject(null);
public selectedJobsiteSubject = new BehaviorSubject(null);
public selectedJobSubject = new BehaviorSubject(null);
public addJobsiteSubject = new BehaviorSubject(null);
}
I have one side bar component which needs to be refreshed everytime on the next method or any new value gets emitted from various components.
side bar is the common component where all these subjects are subscribed in ngOnInit method and these subjects are being next (I mean emit values from various respected components)
Problem
Each and every time these subjects gets called by itself and the respected logic gets called when no respective components are instantiated or are not in life cycle.
was not able to retrive the cause of it also tried to comment the code from where it gets next still gets called automatically.
Any help would be highly appreciated.