-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: multiple actions support and api improvements #2
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, left a few comments. Also, we could rename the deleteToast
method as part of the toast instance received in the onClick
callback to dismiss
to be consistent with the existing API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left a few minor comments, not blockers per se, can be revisited separately.
setTimeout(() => { | ||
emit('removeToast', props.toast) | ||
}, TIME_BEFORE_UNMOUNT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll be good to obtain a reference to the timeout ID returned by the inner setTimeout
call and clear it during the unmount phase.
setTimeout(() => { | ||
emit('removeToast', props.toast) | ||
}, TIME_BEFORE_UNMOUNT) | ||
return timeoutId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need not return the timeoutID
since it's available in the global scope and consumed in the unmount life cycle hook.
action: { | ||
label: 'Confirm', | ||
onClick: () => { | ||
toast.dismiss() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referring to the toast
instance from the onClick
callback here can prevent closing other toasts.
This PR adds support for multiple actions.
Example:
Added new callback parameter in
onClick
function which through we can now pass thedeleteToast
function. And call it if it's needed. The function acceptsdelay
as parameter to delete the toast.