seniv / react-native-notifier

Fast and simple in-app notifications for React Native
MIT License
1.05k stars 60 forks source link

Feature: support of message id so a similar notification just replaces the current one #55

Closed pke closed 2 years ago

pke commented 2 years ago

It would be nice if we could have an "id" associated with a message, that will then lead to the current notification with the same id to just change its content and play a little wiggle animation (or pulse or something).

seniv commented 2 years ago

Hey @pke, can you provide a use-case where this feature can be useful? Since this library can display only one notification per time, I think it will be enough to have something like updateCurrentNoficiation method. But I might be wrong, and that's why I need to know how you are planning to use it  🙂

pke commented 2 years ago

Use-Case Shopping Cart: When the user adds a product to the cart a toast is displayed "{product} added to cart". When the user adds this product again while the toast is still displayed the timeout for the toast should reset and it should change its text to the new text.

show({ id: product.id, content: `${product.name} added to card`})

// later
show({ id: product.id, content: `2 x ${product.name} are in the cart now`})

The notifications can have a unique id set by the caller and if the notification with this id is still displayed it just updates its props and resets its timeout.

Does this make it clearer?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.