send notifications over SSE to be displayed inside the app

This commit is contained in:
m5r
2022-06-19 17:57:51 +02:00
parent a46a4a3861
commit 6cf2f8cb94
13 changed files with 146 additions and 63 deletions

View File

@ -0,0 +1,15 @@
import { EventEmitter } from "events";
import type { NotificationPayload } from "~/utils/web-push.server";
declare global {
var notifications: EventEmitter;
}
global.notifications = global.notifications || new EventEmitter();
export const events = global.notifications;
export function notifySSE(payload: NotificationPayload) {
global.notifications.emit("notification", payload);
}