소스 검색

Commentary polling

master
kj1352 4 년 전
부모
커밋
6857a7f503
1개의 변경된 파일15개의 추가작업 그리고 1개의 파일을 삭제
  1. +15
    -1
      src/app/match-details/match-details.page.ts

+ 15
- 1
src/app/match-details/match-details.page.ts 파일 보기

@@ -63,6 +63,8 @@ export class MatchDetailsPage implements OnInit {


commentaryList: Array<RawCommentary> = []; commentaryList: Array<RawCommentary> = [];


commentaryInterval: any;

constructor( constructor(
private location: Location, private location: Location,
private route: ActivatedRoute, private route: ActivatedRoute,
@@ -77,12 +79,24 @@ export class MatchDetailsPage implements OnInit {
this.currentMatch = match_data; this.currentMatch = match_data;
}); });


this.callCommentary(match_id);

this.commentaryInterval = setInterval(() => {
this.callCommentary(match_id);
}, 30000);
}

callCommentary(match_id) {
this.matchService.getCommentary(match_id).then((data: Array<RawCommentary>) => { this.matchService.getCommentary(match_id).then((data: Array<RawCommentary>) => {
this.commentaryList = data; this.commentaryList = data;
}, (err) => { }, (err) => {
console.log(err); console.log(err);
this.toastService.presentToastWithOptions("Failed to fetch Commentary", "danger"); this.toastService.presentToastWithOptions("Failed to fetch Commentary", "danger");
})
});
}

ngOnDestroy() {
clearInterval(this.commentaryInterval);
} }


getReversedArray(array: Array<RawCommentary>) { getReversedArray(array: Array<RawCommentary>) {


불러오는 중...
취소
저장