mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
add start and stop methods, move subscribe out of constructor
This commit is contained in:
@@ -18,8 +18,6 @@ export class ETANotificationScheduler {
|
||||
this.etaSubscriberCallback = this.etaSubscriberCallback.bind(this);
|
||||
this.sendEtaNotificationImmediately = this.sendEtaNotificationImmediately.bind(this);
|
||||
this.sendEtaNotificationImmediatelyIfSecondsRemainingBelowThreshold = this.sendEtaNotificationImmediatelyIfSecondsRemainingBelowThreshold.bind(this);
|
||||
|
||||
this.shuttleRepository.subscribeToEtaUpdates(this.etaSubscriberCallback);
|
||||
}
|
||||
|
||||
private async sendEtaNotificationImmediately(notificationData: ScheduledNotification): Promise<boolean> {
|
||||
@@ -81,4 +79,13 @@ export class ETANotificationScheduler {
|
||||
|
||||
return await this.sendEtaNotificationImmediately(notificationObject);
|
||||
}
|
||||
|
||||
// The following is a workaround for the constructor being called twice
|
||||
public startListeningForUpdates() {
|
||||
this.shuttleRepository.subscribeToEtaUpdates(this.etaSubscriberCallback);
|
||||
}
|
||||
|
||||
public stopListeningForUpdates() {
|
||||
this.shuttleRepository.subscribeToEtaUpdates(this.etaSubscriberCallback);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user