The library exposes a
toast.promise function. Supply a promise or a function that return a promise and the notification will be updated if it resolves or fails. When the promise is pending a spinner is displayed.
Let's start with a simple example
toast.promise return the provided promise so you can chain it
Displaying a simple message is what you would want to do in 90% of cases. But what if the message you want to display depends on the promise response, what if you want to change some options for the error notification? Rest assured, under the hood, the library uses
toast.update. Thanks to this, you have full control over each notification.
Because you have the full power of
toast.update, you can even supply a custom transition if you want 🤯
If you want to take care of each step yourself you can use
toast.loading and update the notification yourself.