From 6cbf1f29f15f803d49c74c7e6ebea28c98254c91 Mon Sep 17 00:00:00 2001 From: chia-yh <0.chiayuhong.0@gmail.com> Date: Thu, 6 Jul 2023 15:40:01 +0800 Subject: [PATCH 01/12] Add polling, reset methods to label.service.ts --- src/app/core/services/label.service.ts | 43 ++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/app/core/services/label.service.ts b/src/app/core/services/label.service.ts index 77e107e4..985b20d2 100644 --- a/src/app/core/services/label.service.ts +++ b/src/app/core/services/label.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; +import { BehaviorSubject, EMPTY, Observable, Subscription, timer } from 'rxjs'; +import { catchError, exhaustMap, map } from 'rxjs/operators'; import { Label } from '../models/label.model'; import { GithubService } from './github.service'; @@ -22,9 +22,39 @@ const COLOR_WHITE = 'ffffff'; // Light color for text with dark background * from the GitHub repository for the WATcher application. */ export class LabelService { + static readonly POLL_INTERVAL = 5000; // 5 seconds + labels: Label[]; + labels$: BehaviorSubject; + + private labelsPollSubscription: Subscription; + + constructor(private githubService: GithubService) { + this.labels$ = new BehaviorSubject(new Array