In my component html, I am using the asyncPipe to subscribe to this http service. The service maps the json response object to an array of class instances. This all works great, but I would like http service to poll every few seconds. I've tried a bunch of things (like interval), but it seems RXJS is a bit of a minefield at the moment. Has anyone implemented this kind of thing using Angular 6?
fetch(command, params?) {
return this.http.post(`http://localhost:4000/${command}`, params)
.pipe(
map((data: Data) => {
const statuses: Status[] = [];
for (const statusKey of Object.keys(data.statuses)) {
const newStatus = new Status(
// do some object translation...
);
statuses.push(newStatus);
}
return statuses;
})
)
.pipe(
catchError(EpisodeApiService.handleError)
);
}