From b0f04a92561590da34a94eb32b8baaf64c359abd Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Thu, 27 Mar 2025 11:10:49 -0700 Subject: [PATCH] add stub methods for subscribe/unsubscribe --- .../InMemoryNotificationRepository.ts | 15 ++++++++++++++- src/repositories/NotificationRepository.ts | 6 ++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/repositories/InMemoryNotificationRepository.ts b/src/repositories/InMemoryNotificationRepository.ts index ecd3e7b..78a4834 100644 --- a/src/repositories/InMemoryNotificationRepository.ts +++ b/src/repositories/InMemoryNotificationRepository.ts @@ -1,4 +1,10 @@ -import { NotificationLookupArguments, NotificationRepository, ScheduledNotification } from "./NotificationRepository"; +import { + Listener, + NotificationEvent, + NotificationLookupArguments, + NotificationRepository, + ScheduledNotification +} from "./NotificationRepository"; import { TupleKey } from "../types/TupleKey"; type DeviceIdSecondsThresholdAssociation = { [key: string]: number }; @@ -13,6 +19,8 @@ export class InMemoryNotificationRepository implements NotificationRepository { */ private deviceIdsToDeliverTo: { [key: string]: DeviceIdSecondsThresholdAssociation } = {} + private subscribers: Listener[] = []; + async getAllNotificationsForShuttleAndStopId(shuttleId: string, stopId: string) { const tuple = new TupleKey(shuttleId, stopId); if (this.deviceIdsToDeliverTo[tuple.toString()] === undefined) { @@ -76,4 +84,9 @@ export class InMemoryNotificationRepository implements NotificationRepository { delete this.deviceIdsToDeliverTo[tupleKey.toString()][deviceId]; } + public subscribeToNotificationChanges(listener: Listener): void { + } + + public unsubscribeFromNotificationChanges(listener: Listener): void { + } } diff --git a/src/repositories/NotificationRepository.ts b/src/repositories/NotificationRepository.ts index 8e6fdef..0f4ff86 100644 --- a/src/repositories/NotificationRepository.ts +++ b/src/repositories/NotificationRepository.ts @@ -14,6 +14,8 @@ export interface ScheduledNotification extends NotificationLookupArguments { secondsThreshold: number; } +export type Listener = ((event: NotificationEvent) => any); + export interface NotificationEvent { notification: ScheduledNotification, event: 'delete' | 'addOrUpdate' @@ -26,6 +28,6 @@ export interface NotificationRepository { addOrUpdateNotification(notification: ScheduledNotification): Promise; deleteNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise; - subscribeToNotificationChanges(listener: (event: NotificationEvent) => any): void; - unsubscribeFromNotificationChanges(listener: (event: NotificationEvent) => any): void; + subscribeToNotificationChanges(listener: Listener): void; + unsubscribeFromNotificationChanges(listener: Listener): void; }