I have a simple function, included in a service, returning an observable of an object:
private someData;
getDataStream(): Observable<any> {
return Observable.of(this.someData);
}
I subscribe to this function onInit of a component:
private somethingsomething;
ngOnInit() {
this.dataService.getDataStream().subscribe(
(data) => {
this.somethingsomething = data; // WORKS AND ALWAYS UP TO DATE
console.log(data); // ONLY WORKS ONCE
}
)
}
As commented, the data when given to a variable, which is then displayed in the view, is always fine. But the console.log on the other hand is only triggered once, and then never again.
How can I console.log the data whenever it changes?