add stub methods for subscribe/unsubscribe

This commit is contained in:
2025-03-27 11:10:49 -07:00
parent b2fb430a38
commit b0f04a9256
2 changed files with 18 additions and 3 deletions

View File

@@ -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 {
}
}

View File

@@ -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<void>;
deleteNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise<void>;
subscribeToNotificationChanges(listener: (event: NotificationEvent) => any): void;
unsubscribeFromNotificationChanges(listener: (event: NotificationEvent) => any): void;
subscribeToNotificationChanges(listener: Listener): void;
unsubscribeFromNotificationChanges(listener: Listener): void;
}