UNPKG

gazeplotter

Version:

Gazeplotter is a Svelte application for visualizing eye-tracking data.

37 lines (36 loc) 929 B
import { writable } from 'svelte/store'; export const toastStore = writable([]); export const addToast = (toast) => { toastStore.update(toasts => [...toasts, toast]); }; export const addErrorToast = (message) => { addToast({ id: getUniqueToastId(), title: 'Error', message, type: 'error', duration: 8000, }); }; export const addSuccessToast = (message) => { addToast({ id: getUniqueToastId(), title: 'Success', message, type: 'success', duration: 3000, }); }; export const addInfoToast = (message) => { addToast({ id: getUniqueToastId(), title: 'Info', message, type: 'info', duration: 8000, }); }; const getUniqueToastId = () => { /* Not date dependent, because it is possible to add multiple toasts in one millisecond */ return Math.floor(Math.random() * 1000000000); };