Expose an .update function [feature request]
sethsnel opened this issue · 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.
@juliancwirko What do you think about this idea?
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.
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.
I would need to play with this. Could you provide a small reproduction repository?
I added the feature locally and created a merge request for if you'd like to add it to the base plugin.
@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.
I'm using this update feature too.
It would be great if it could be merged with the master branch.
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.