Currently learning RxJS. I have an integer selectedCourseIndex within a service that I\'d like a separate component to subscribe to.
courses-sec
"Subject" observable does not replay the previous values on subscribe. Your subscription will only fire if you do the following in your service [somehow] -
this.selectedCourseIndexUpdated.next();
To fire subscription on each subscribe [to get the last emitted value] you should use "BehaviorSubject" instead of Subject like -
private selectedCourseIndexUpdated = new BehaviorSubject(0);
BehaviorSubject replay the last emitted value on each subscription. Notice BehaviorSubject constructor takes the default value.