You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

26 lines
557 B

export const useToast = defineStore('Toast', () => {
type ToastInterface = {
publish: (e: { title: string; message: string }) => void;
};
type ToastRef = Ref<null | ToastInterface>;
const toast = ref<Ref<ToastRef> | null>(null);
function setToast(toastInstance: ToastRef) {
toast.value = toastInstance;
}
function showToast({
title,
message,
}: {
type: 'success' | 'error';
title: string;
message: string;
}) {
toast.value?.value?.publish({ title, message });
}
return { setToast, showToast };
});