How can I pass a value from one client side plugin action to another?

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.

It’s not clear what do you mean by

1 Like

You can pass data on the window :wink:

Then how would a plugin user pull it into any element? I’d have to programmatically build a custom element for them to do that.

I want them to be able to pull it from the window into like an input field or wherever they want.

Despite your desire to have this not be an element plugin, you need this to be an element plugin. Element plugins have exposed states.

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.

An element plugin is an element plugin. Have you not used one before?

1 Like

Nope never used one, all I know is what’s in the docs. I know very little about No-Code or bubble. I just have a background Software Development.

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

2 Likes

Noted, thanks!