Subscribe to shuttle events and add stub methods

This commit is contained in:
2025-11-11 18:56:46 -08:00
parent 6cf61d1cdb
commit bc7ba7d507

View File

@@ -1,8 +1,9 @@
import { SelfUpdatingETARepository } from "./SelfUpdatingETARepository";
import { BaseRedisETARepository } from "./BaseRedisETARepository";
import { createClient, RedisClientType } from "redis";
import { ShuttleGetterRepository, ShuttleTravelTimeDataIdentifier, ShuttleTravelTimeDateFilterArguments } from "../ShuttleGetterRepository";
import { ShuttleGetterRepository, ShuttleRepositoryEvent, ShuttleStopArrival, ShuttleTravelTimeDataIdentifier, ShuttleTravelTimeDateFilterArguments } from "../ShuttleGetterRepository";
import { REDIS_RECONNECT_INTERVAL } from "../../../environment";
import { IShuttle } from "../../../entities/ShuttleRepositoryEntities";
export class RedisSelfUpdatingETARepository extends BaseRedisETARepository implements SelfUpdatingETARepository {
constructor(
@@ -23,7 +24,21 @@ export class RedisSelfUpdatingETARepository extends BaseRedisETARepository imple
throw new Error("Method not implemented.");
}
startListeningForUpdates(): void {
throw new Error("Method not implemented.");
startListeningForUpdates() {
this.shuttleRepository.addListener(ShuttleRepositoryEvent.SHUTTLE_UPDATED, this.handleShuttleUpdate);
this.shuttleRepository.addListener(ShuttleRepositoryEvent.SHUTTLE_ARRIVED_AT_STOP, this.handleShuttleArriveAtStop)
}
stopListeningForUpdates() {
this.shuttleRepository.removeListener(ShuttleRepositoryEvent.SHUTTLE_UPDATED, this.handleShuttleUpdate);
this.shuttleRepository.removeListener(ShuttleRepositoryEvent.SHUTTLE_ARRIVED_AT_STOP, this.handleShuttleArriveAtStop);
}
private handleShuttleUpdate(shuttle: IShuttle) {
// TODO: handle shuttle update
}
private handleShuttleArriveAtStop(shuttleArrival: ShuttleStopArrival) {
// TODO: handle shuttle arrive at stop
}
}