Files
genieacs/ui/notifications.ts
T
2019-02-20 03:36:52 -08:00

24 lines
472 B
TypeScript

import m from "mithril";
interface Notification {
type: string;
message: string;
timestamp: number;
}
const notifications = new Set<Notification>();
export function push(type, message): void {
const n = { type: type, message: message, timestamp: Date.now() };
notifications.add(n);
m.redraw();
setTimeout(() => {
notifications.delete(n);
m.redraw();
}, 4000);
}
export function getNotifications(): Set<Notification> {
return notifications;
}