I am currently experimenting with data sharing between two sibling components by utilizing an injectable service. Within my injectable, I have implemented an observable in the following manner:
@Injectable()
export class DatasService {
message: Observable<string> = new Observable<string>();
changeMessage(){
this.message.next('Arpita'); //Property next doesn't exist
}
changeMessage2(){
this.message.next('Ankan');
}
}
However, when I replace Observable with Subject, everything works smoothly. Is there a way to achieve the desired functionality while sticking to using Observable instead of Subject? As a newcomer to reactive programming, I find myself feeling confused about this.