mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
add stub methods for subscribe/unsubscribe
This commit is contained in:
@@ -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 {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user