I'm trying to subscribe to an observable and log it's value.
Flow:
this.myObservable$ = new Subject<string>();
this.myObservable$.next('hello world') //in (angular) service A
wait a few seconds
let newObservable$ = this.myObservable$.asObservable().subscribe(message => console.log(message)); //subscribe in service B, nothing happens
But this didn't work since I subscribed too late. But even with a shareReplay this does not work.
let newObservable$ = this.myObservable$.asObservable()
.pipe(
shareReplay(1),
)
.subscribe(message => console.log(message)); //also nothing happens
Can anyone help me understand why I can't 'shareReplay' this observable and get the last emitted value?