-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add auto closing timing logic for toasts
- Loading branch information
1 parent
89c0dbb
commit 76ded24
Showing
3 changed files
with
42 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
import type { ToastMessage } from "../domain/models/toastMessage"; | ||
import { toastStore } from "../stores/toast"; | ||
|
||
const MAX_TOASTS_SHOWN = 3; | ||
|
||
export function showToast(message: ToastMessage) { | ||
toastStore.update((toasts: ToastMessage[]) => [ | ||
message, | ||
...toasts.slice(0, MAX_TOASTS_SHOWN), | ||
]); | ||
toastStore.set(message); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { writable } from "svelte/store"; | ||
import type { Writable } from "svelte/store"; | ||
|
||
export const toastStore: Writable<any[]> = writable([]); | ||
export const toastStore: Writable<any> = writable(null); |