I have a client-side plugin action that calculates a value. I want to use this value in another plugin action called “Set Element State”. For example, when a button is clicked, the custom plugin action calculates a value. This value is then passed to the “Set Element State” action, which updates the state of an element with the calculated value.
Workflow:
Button get clicked → Custom Plugin Action calculates some value → value is passed to Set Element state action → Set element state action updates some element state with the calculated value.
I’d also like to add that I don’t want this to be a Plugin Element Action because I’d like the plugin user to be able to “attach” this calculation to any element and have it update any element.
Unfortunately client side actions don’t return values.
If you want to share data between actions of plugin you have these options:
use an element with a state and create an action from the element. In the action publish the value to the state. Now the value can be accessed from your element or from anything else outside of it.
use an element and create two actions. The first one calcukate the value and save it in the context, the second action can read the value from the context. The value is accessible only from actions of the same element instance.
use any kind of action (from an element or not) and save the value in the window object. The value is accessible from any code that runs on the page.
Say I do make a Element Plugin,
Can a user customize that element plug I make to be whatever they need? Text, input, field, button ect? I just need to ensure it has the action on it.
Good. It’s useful if you fiddle a bit with some test plugin, to create basic stuff with elements and actions before you develop the plugin you really need. Just to get used with the bubble dx and its quirks