f3oall / awesome-notifications

Lightweight JavaScript Notifications Library
https://f3oall.github.io/awesome-notifications/
MIT License
286 stars 40 forks source link

Callback when a notification is dismissed or is's reached its timeout. #11

Closed adrianoviana87 closed 5 years ago

adrianoviana87 commented 5 years ago

Is your feature request related to a problem? Please describe. I need to avoid duplicated notifications.

Describe the solution you'd like It would be nice to have a callback indicating that the notifications was closed so I can decide whether to show another one with the same text or not.

Describe alternatives you've considered I considered waiting for the notification's timeout but the user can dismiss it before.

Additional context Multiple notifications happen when the user is on a page for a long time and the token for the api has expired. When multiple requests are made in this scenario, the interceptor dispatches the same notification for each request, causing the same notification to be shown multiple times at once. Since I use this awesome lib through some kind of proxy, I would be able to decide whether to show the message or not if I could know if the previous message is already closed.

f3oall commented 5 years ago

Hey in version 3.0.0, all notifications methods will return you an HTMLElement which was created. So you can save it in some variable, and then check if it's still exist. Does it solve your issue?

Version 3.0.0 is coming this week.

adrianoviana87 commented 5 years ago

Thank you for your reply. It would surely be enough for me. Looking forward to upgrade!