kbrgl / svelte-french-toast

🍞🥂 Buttery smooth toast notifications for Svelte
https://svelte-french-toast.vercel.app/
MIT License
838 stars 30 forks source link

Update an existing toast? #10

Closed nickyhajal closed 1 year ago

nickyhajal commented 1 year ago

Is there any way to get a reference to an existing toast if visible and update it directly?

If someone saves several times, I'd love to show some kind of feedback in the existing toast instead of showing 4 in a row of the same thing.

kbrgl commented 1 year ago

In general, if it's possible in react-hot-toast, it should be possible here. Each of the toast functions returns a toast ID that you can use to update or dismiss it. You should be able to do this (straight from the react-hot-toast docs):

const toastId = toast.loading('Loading...');

// ...

toast.success('This worked', {
  id: toastId,
});

Let me know if that doesn't work for you!