Files
ss-tools/frontend/.svelte-kit/output/server/chunks/toasts.js

17 lines
640 B
JavaScript

import { w as writable } from "./index.js";
const toasts = writable([]);
function addToast(message, type = "info", duration = 3e3) {
const id = Math.random().toString(36).substr(2, 9);
console.log(`[toasts.addToast][Action] Adding toast context={{'id': '${id}', 'type': '${type}', 'message': '${message}'}}`);
toasts.update((all) => [...all, { id, message, type }]);
setTimeout(() => removeToast(id), duration);
}
function removeToast(id) {
console.log(`[toasts.removeToast][Action] Removing toast context={{'id': '${id}'}}`);
toasts.update((all) => all.filter((t) => t.id !== id));
}
export {
addToast as a,
toasts as t
};