[New Plugin] BNS - Global Custom States [EDIT]

Hi everyone,

With @bestbubbledev , we’re very proud to present you another new plugin BNS - Global Custom State: BNS - Global Custom State Plugin | Bubble

Tutorial

Description

(BNS - Global Custom State · BNS)
This plugin allows you to share Global Custom States between all the reusables and repeating groups (however deeply nested) on a page level.

You can create Global Custom States dynamically and set their values dynamically.

BNS - Global Custom State - Frame 1.jpg

Demo

You can access the demo here : https://bnsplugins.bubbleapps.io/version-test/gcs

Instructions

Drop the plugin element where you want to access your Global Custom State.

Hint: it is better, for use, to create the Global Custom States at the page level. However, you can create it whenever you want.

Note: if the element is dropped into a collapsed element (group, reusable element, popup), it won’t be created nor accessible until the element is made visible.

You can then set :

  • the name of your Global Custom State
  • its datatype
  • its Default Value
  • its Default List

image.png

Each Global Custom State can handle a single value AND a list, both of the same datatype. You can respectively access the single value and the list value by using <plugin element’s name>'s Global Custom State Value and <plugin element’s name>'s Global Custom State List.

To set the value in a workflow (like the “set states of an element” action) to the Single Value or the List Value by using the respective actions Set State Value and Set State List.

image.pngimage.png

Use cases

Whenever you need to share a value through all the element that are on a page, whether directly on the page or even however deeply nested into reusable elements and repeating groups.

Global Custom States can be dynamically created (ie if for a Global Custom State Element you set its name dynamically, it’ll create as many GCS Values as there’re names).

Note : it works only at the page level and not app wide. Moreover, whenever you refresh the page, all the Global Custom States values are reset.

Any comment or feedback very very much appreciated :slight_smile:

Best regards,

Guillaume Maison
BestNocodeStudio.com

1 Like

Looks like it has the potential tial to be a great tool. Eager to try it out.

I’m feedback is that if you get the data to be consistent upon refreshed and other pages you’d be golden!

I often need such feature and use url parameters to e sure refresh and navigation but it’s a pain to set up.for each app individually

it’s on the roadmap :slight_smile:

1 Like

You know have a tutorial made by @bestbubbledev here : https://www.youtube.com/watch?v=X65AlR-aSw8

Hi there, will there be a possibility to store multiple states in 1 element? This is to minimize the number of elements in the main page level. :slight_smile:

Another thing, can values from these, realtime? Like when a table changes, also update the values from this global state?

If you dynamically change the name of the Global Custom State element, it’ll create dynamically a new Global Custom State with this new name while keeping the first one too. Both will be available (if you dynamically change the name accordingly).

But they’ll be both of the same datatype.

It’s just frontend.
So, if you set the Default value to something coming from the DB (like with a Do Search), it’ll change the value and broadcast it to all other GCS elements pointing to this GCS.

  1. What happens in the background if you have 2 GCS elements with the same state name and same default values? Does the app still loads or consumes 2 searches?

  2. Also what happens when you have 2 GCS with the same state name but with different default values? What will be the resulting value?

Let’s say, the 2 gcs element both in different reusable element, same state name, different default values. Upon page load, both reusable elements are present. What will be the value of that state name?

  1. What happens in the background if you have 2 GCS elements with the same state name and same default values? Does the app still loads or consumes 2 searches?

Yes it will consume 2 searches. You should set default value to only 1 of them. As i don’t master how Bubble sequence the element’s creation, i would suggest to set the default value onto the element dropped on the page.

  1. Also what happens when you have 2 GCS with the same state name but with different default values? What will be the resulting value?

Only the first one to be created handle the value. Every other GCS created with same name & datatype will get the first GCS value. The only way after that to modify the value is to use the action Set State Value (or to have a dynamic default value).

Let’s say, the 2 gcs element both in different reusable element, same state name, different default values. Upon page load, both reusable elements are present. What will be the value of that state name?

The value of the first one to be created… But i don’t know how Bubble handle the plugin element creation order … Tests must be made… I did some but never get very conclusive …

Thanks for the answers. Helped me very much. :smiley:

Do you have plans to support Realtime Values for “Set State Value”?
I mean, use an action to set the value without losing the realtime functionality of that value/search?

When you drop the element on a page, you can set its value (single as list).

But when you use the Set State Value action, it overrides the default value and is definitely set to the value used with the action.

What you’re asking would mean to handle for the single & the list values a sibbling that would remain the default value and the current value.

Is that what you mean ?

A bit of information about rules of precedence when using multiple GCS elements for 1 gcs name :

  1. when the first GCS element is created, it becomes “the master” and sets the value to its default value field
  2. when following GCS elements are created onto the same gcs name, the default value that might be set here is ignored.
  3. if “the master” value is modified (with a dynamic do search for example), then all the other values are modified “instantaneously” (the Bubble way).
  4. if any of the GCS elements (master as not master) uses “Set State Value”, the default value is overridden and the “last one that have set State Value” is right.