react-s-alert icon indicating copy to clipboard operation
react-s-alert copied to clipboard

Expose an .update function [feature request]

Open sethsnel opened this issue 8 years ago • 8 comments

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 avatar May 08 '17 15:05 sethsnel

@juliancwirko What do you think about this idea?

sethsnel avatar May 15 '17 09:05 sethsnel

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.

juliancwirko avatar May 15 '17 09:05 juliancwirko

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.

sethsnel avatar May 15 '17 12:05 sethsnel

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

juliancwirko avatar May 15 '17 12:05 juliancwirko

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

sethsnel avatar May 15 '17 13:05 sethsnel

@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.

sethsnel avatar May 23 '17 13:05 sethsnel

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

marcselman avatar Nov 14 '17 13:11 marcselman

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.

juliancwirko avatar Nov 14 '17 14:11 juliancwirko