Here is a method that I am using:
export class PeriodicData {
public checkForSthPeriodically(): Subscription {
return Observable.interval(10000)
.subscribe(() => {
console.log('I AM CHECKING');
this.getData();
});
};
public getData(): Observable<MyObject> {
let objects: MyObject[] = this.filterData();
return Observable.from(objects);
}
public filterData(): MyObject[] {
let someData;
// someData = filter(...) // logic to filter data
return someData;
}
}
I have another class where I subscribe to getData()
:
class Another {
constructor(private periodicData: PeriodicData ) {
this.periodicData.getData().subscribe(obj => {
console.log('IN ANOTHER CLASS');
});
}
}
However, the "IN ANOTHER CLASS" message is not getting logged. What could be missing in my code?