You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current API for adding toasts uses separate functions for each type:
toast('A simple toast')// type = 'blank'toast.success('A successful toast')toast.error('An error toast')
This is an excellent API for direct programmatic access!
But it's a bit unwieldy for abstraction. If I want to build a mechanism for defining toasts server-side, then passing the data to the client, then showing a toast, I need to use a switch statement on type to decide which of these functions to call.
I'd love to be able to do this:
toast({message: 'A simple toast'})toast({message: 'A successful toast',type: 'success'})toast({message: 'An error toast',type: 'error'})
not because I want to write that code, but because I want to write this code:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The current API for adding toasts uses separate functions for each type:
This is an excellent API for direct programmatic access!
But it's a bit unwieldy for abstraction. If I want to build a mechanism for defining toasts server-side, then passing the data to the client, then showing a toast, I need to use a
switch
statement ontype
to decide which of these functions to call.I'd love to be able to do this:
not because I want to write that code, but because I want to write this code:
instead of having to do this:
Beta Was this translation helpful? Give feedback.
All reactions