So I have a service http function which return an Observable<any[]>. I call this function every minute in the component and I want to compare the length of the previously returned array with the length of the newly returned array.How can I do this?
This is the service method:
public getMatchIncident(matchId: number): Observable<any[]>{
return this.http.get<any>(this.url + matchId);
}
This is the component function:
private getMatchIncident(matchId: number): void {
this.matchService.getMatchIncident(matchId).subscribe(event => {
const previousLength = this.incidents.length;
const newLength = event.length;
this.incidents = event;
});
}
But it doesn't work well... How can I solve this problem?