Skip to content

Instantly share code, notes, and snippets.

@el3um4s
Created October 15, 2022 13:56
Show Gist options
  • Save el3um4s/8f2eebac72046fdfbf0afe7e45bd108b to your computer and use it in GitHub Desktop.
Save el3um4s/8f2eebac72046fdfbf0afe7e45bd108b to your computer and use it in GitHub Desktop.
MEDIUM - How To Show Notifications in Web Application - 01
import { writable } from "svelte/store";
import type { Writable } from "svelte/store";
const TIMEOUT = 3000;
type MessageType = "default" | "danger" | "warning" | "info" | "success";
export interface Msg {
type: MessageType;
message: string;
timeout?: number;
}
interface Message {
id: string;
msg: Msg;
}
const notificationStore: Writable<Message[]> = writable([]);
const notifications = {
subscribe: notificationStore.subscribe,
};
export default notifications;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment