send notifications over SSE to be displayed inside the app
This commit is contained in:
15
app/utils/events.server.ts
Normal file
15
app/utils/events.server.ts
Normal 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);
|
||||
}
|
Reference in New Issue
Block a user