mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +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";
|
import { TupleKey } from "../types/TupleKey";
|
||||||
|
|
||||||
type DeviceIdSecondsThresholdAssociation = { [key: string]: number };
|
type DeviceIdSecondsThresholdAssociation = { [key: string]: number };
|
||||||
@@ -13,6 +19,8 @@ export class InMemoryNotificationRepository implements NotificationRepository {
|
|||||||
*/
|
*/
|
||||||
private deviceIdsToDeliverTo: { [key: string]: DeviceIdSecondsThresholdAssociation } = {}
|
private deviceIdsToDeliverTo: { [key: string]: DeviceIdSecondsThresholdAssociation } = {}
|
||||||
|
|
||||||
|
private subscribers: Listener[] = [];
|
||||||
|
|
||||||
async getAllNotificationsForShuttleAndStopId(shuttleId: string, stopId: string) {
|
async getAllNotificationsForShuttleAndStopId(shuttleId: string, stopId: string) {
|
||||||
const tuple = new TupleKey(shuttleId, stopId);
|
const tuple = new TupleKey(shuttleId, stopId);
|
||||||
if (this.deviceIdsToDeliverTo[tuple.toString()] === undefined) {
|
if (this.deviceIdsToDeliverTo[tuple.toString()] === undefined) {
|
||||||
@@ -76,4 +84,9 @@ export class InMemoryNotificationRepository implements NotificationRepository {
|
|||||||
delete this.deviceIdsToDeliverTo[tupleKey.toString()][deviceId];
|
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;
|
secondsThreshold: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Listener = ((event: NotificationEvent) => any);
|
||||||
|
|
||||||
export interface NotificationEvent {
|
export interface NotificationEvent {
|
||||||
notification: ScheduledNotification,
|
notification: ScheduledNotification,
|
||||||
event: 'delete' | 'addOrUpdate'
|
event: 'delete' | 'addOrUpdate'
|
||||||
@@ -26,6 +28,6 @@ export interface NotificationRepository {
|
|||||||
addOrUpdateNotification(notification: ScheduledNotification): Promise<void>;
|
addOrUpdateNotification(notification: ScheduledNotification): Promise<void>;
|
||||||
deleteNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise<void>;
|
deleteNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise<void>;
|
||||||
|
|
||||||
subscribeToNotificationChanges(listener: (event: NotificationEvent) => any): void;
|
subscribeToNotificationChanges(listener: Listener): void;
|
||||||
unsubscribeFromNotificationChanges(listener: (event: NotificationEvent) => any): void;
|
unsubscribeFromNotificationChanges(listener: Listener): void;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user