juliancwirko / react-s-alert

Alerts / Notifications for React with rich configuration options
https://www.npmjs.com/package/react-s-alert
MIT License
649 stars 75 forks source link

Expose an .update function [feature request] #43

Open sethsnel opened 7 years ago

sethsnel commented 7 years ago

Dear @juliancwirko,

S-Alert already exposes several functions to interact with alerts such as: Alert.success(message, configObj) Alert.close(alertId)

However, we have a use-case in which it is required to update a generated Alert. We use a custom contentTemplate and provide customFields. In our use-case, we would like the Alert to be rerendered with updated customFields. A method with this signature would be sufficient: Alert.update(alertId, updatedCustomFields)

Do you think this would fit for S-Alert?

Kind regards.

sethsnel commented 7 years ago

@juliancwirko What do you think about this idea?

juliancwirko commented 7 years ago

Hi, I am not sure if I understood it right, but If you need to update the alert's fields you should be able to do this in a standard way in React using state. I think this shouldn't be in the scope of this package, but as I said I might not understood it well.

sethsnel commented 7 years ago

After calling Alert.success(message, configObj) an Alert opens. Our custom Notification contentTemplate renders dynamically based on certain customFields.

It's possible that values provided as customFields change (indeed as a result of updating React state). However, already opened Alerts won't be affected. So I would like a method to update the customField values for already opened Alerts.

juliancwirko commented 7 years ago

I would need to play with this. Could you provide a small reproduction repository?

sethsnel commented 7 years ago

I added the feature locally and created a merge request for if you'd like to add it to the base plugin.

sethsnel commented 7 years ago

@juliancwirko Have you yet considered adding this extension to the plugin? It would be great, because we now use a local detached version of your plugin. And it would be nice to just use an updated version from NPM.

marcselman commented 6 years ago

I'm using this update feature too. It would be great if it could be merged with the master branch.

juliancwirko commented 6 years ago

Hi, I think I need couple of things to be able to merge this. @sethsnel could you provide some documentation for this in Readme.md file? We have broken tests so for now we don't need them here.

Also could you tell something more about why we have it only for custom fields? Thanks.