How to make two reusables 'talk to' one another?

I have a group with two reusables - reusable A’s custom state needs to change when an input on reusable B is changed. In otherwords, reusable B has to change reusable A.

This has proven to be trickier than I thought! Does anyone have a solution to this?

Two ideas come to mind: via the url or via custom triggers. Ah, yeah, there are certainly some plugins to help this.

I’ve recently started experimenting with triggers and I like the results so far.

2 Likes

Just pass data via states and a “update” tigger state (yes/no type).

  1. Set state to yes on reusable
  2. Have a condition when yes in the reusable trigger actions that use the data of the data stae
  3. Set its own yes no state to no again

That way you can pass data fast between unlimited amount of reusables.

Bubble obviously need to make a “when data change” tigger, but the hack works for now

Thanks very much guys, I will try both your ideas today and let you know how I get on :slight_smile:

1 Like

This won’t work because you can’t make one reusable ‘listen’ to the result of the first. If you add a Yes/No to reusable 2, that is fine but then when you open reusable 2, there is no way to access that result.

I don’t think this works for my situation because you can only trigger that when clicking something … whereas I need to ‘pull’ the info from another reusable. It’s hard to explain but in my set up, when I click a button on Reusable 2, I need reusable 1 to immediate update.

Yes there is. Its scenario 1. The state data on the RU is absolutely readable. Use this instead of custom events - That way you don’t need to pass data through the slower database.

The concept is to “send” the data you need, or to “request the data” using triggers. Passing it from one RU to INDEX and then to the other RU.

To send data from RU2 to RU1:

  1. In RU2: Push button to > start workflow > and set state X of reusable with relevant data + trigger to “yes”
  2. Index: On trigger (RU2) = “yes” > start workflow > and set state X of RU1 with data from state of RU2 + trigger = “yes” > Set state of RU1 to “No”
  3. Use the data in in RU1 from the state. And vice versa…

To request data in RU1 from RU2:

  1. In RU2 > Push button then > Start workflow > Set trigger A in RU2 = “yes”
  2. In Index > When RU2 tirgger A = “yes” > then start workflow > set RU1 trigger A =“yes” > then set RU2 trigger A =“no”
  3. In RU1 > When trigger A = “yes” then > run workflow > get data from where ever and set state X of RU1 with data and RU1 trigger A = “no” and trigger B = “yes”
  4. In Index > When RU1 trigger B = “yes” > then start workflow > set RU2 trigger B =“yes” > then set RU1 trigger B =“no”
  5. In RU2 use the data where you want

Happens instantly and it works. But would be handy with a “when state data change” trigger added from the bubble team or ability to use states across RU elements. Making this more digestible for humans and even faster.

3 Likes

Thank you @login for that clear information, very much appreciated and now it makes sense. I think this will be useful to other Bubblers also because it’s a deceivingly tricky thing to do.

Another option which I can not believe didn’t come to my mind first is to simply make RU2 make changes to the database, this is then instantly reflected in RU1. However, your method is faster.

1 Like