mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add binding of function and timer
This commit is contained in:
@@ -22,10 +22,13 @@ const baseUrl = "https://passiogo.com/mapGetData.php";
|
|||||||
|
|
||||||
export class RepositoryDataLoader {
|
export class RepositoryDataLoader {
|
||||||
private shouldBeRunning: boolean = false;
|
private shouldBeRunning: boolean = false;
|
||||||
|
private timer: any;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private repository: GetterSetterRepository,
|
private repository: GetterSetterRepository,
|
||||||
) {}
|
) {
|
||||||
|
this.startFetchDataAndUpdate = this.startFetchDataAndUpdate.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
public async start() {
|
public async start() {
|
||||||
if (this.shouldBeRunning) {
|
if (this.shouldBeRunning) {
|
||||||
@@ -52,9 +55,9 @@ export class RepositoryDataLoader {
|
|||||||
await this.fetchAndUpdateEtaDataForExistingOrderedStops();
|
await this.fetchAndUpdateEtaDataForExistingOrderedStops();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
} finally {
|
|
||||||
setTimeout(this.startFetchDataAndUpdate, timeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.timer = setTimeout(this.startFetchDataAndUpdate, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async fetchAndUpdateSystemData() {
|
private async fetchAndUpdateSystemData() {
|
||||||
|
|||||||
Reference in New Issue
Block a user