Skip to content

Commit

Permalink
feat: expose update function
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnartorfis committed Sep 4, 2024
1 parent c2f588e commit ccd199d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { default as Toast } from './components/toast/Toast';
export { Toaster } from './components/toast/Toaster';
export { default as toast } from './utils/toastFunctions';
export { default as toast, updateToast } from './utils/toastFunctions';
export {
ToastVariant,
ToastPosition,
Expand Down
10 changes: 9 additions & 1 deletion src/utils/toastFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { getToastContext } from '../components/toast/Toaster';
import { ToastVariant, type ToastFunction } from '../types/toastTypes';
import {
ToastVariant,
type ToastFunction,
type ToastUpdateFunction,
} from '../types/toastTypes';

const toast: ToastFunction = (title, options) => {
const { addToast } = getToastContext();
return addToast(title, options);
};

export const updateToast: ToastUpdateFunction = (id, options) => {
return getToastContext().updateToast(id, options);
};

toast.success = (title, options = {}) => {
const { addToast } = getToastContext();
return addToast(title, {
Expand Down

0 comments on commit ccd199d

Please sign in to comment.