I have a service with a Subject member. The Subject provides an instance of a class:
public selectedProjectSubject: Subject<Project> = new Subject();
The value of the Subject is updated with a method:
public updateSelectedProject(project: Project) {
this.selectedProjectSubject.next(project);
}
In several classes i subscribe on the Subject:
this.projectSubscription = this.projectService.selectedProjectSubject.subscribe((project: Project) => {
this.projectSelected = project;
});
Is it a good practice to subscribe directly on the Subject or provide the Subject (Observable) with another method?