Created
October 15, 2022 13:56
-
-
Save el3um4s/8f2eebac72046fdfbf0afe7e45bd108b to your computer and use it in GitHub Desktop.
MEDIUM - How To Show Notifications in Web Application - 01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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