# How to create a cloud variable listener for a sub-bucket?

**URL:** <https://community.thunkable.com/t/how-to-create-a-cloud-variable-listener-for-a-sub-bucket/2140238>\
**Category:** Questions about Thunkable X\
**Created:** [November 20, 2022, 7:08pm UTC](https://community.thunkable.com/t/how-to-create-a-cloud-variable-listener-for-a-sub-bucket/2140238 "2022-11-20T19:08:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bibbi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@bibbi](https://community.thunkable.com/u/bibbi)\
**Post date:** [November 20, 2022, 7:08pm UTC](https://community.thunkable.com/t/how-to-create-a-cloud-variable-listener-for-a-sub-bucket/2140238/1 "2022-11-20T19:08:06Z")

</div>

hi

say that cloud variables can be used as a replacement for firebase blocks I find it a bit light  
it is not possible to have dynamic cloud variables let me explain checking a node we can do it but if it contains a set of buckets how do we know which bucket has been modified?

I tried

the problem with the firebase blocks it seems that they work in a random way and it’s not the first time that I use them  
can you make variable clouds more powerful?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 22, 2022, 11:29am UTC](https://community.thunkable.com/t/how-to-create-a-cloud-variable-listener-for-a-sub-bucket/2140238/2 "2022-11-22T11:29:06Z")

</div>

Can you explain by giving an example?

There are two different types of each of the variable classes. Cloud variables can be static (design time) or dynamic (run time)

Static variables can be declared as follows:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/a/aae6a20542f47a2d899f89fae2a308bb04207b5e.png)

Dynamic variables can be used as part of the code, like this

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/4/c4438430d64fd1c02aa1c1f7db770270fff3b39c.png)

or check the value like this  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/a/fa2e91133997acc7de90c1001d0b051d02ecd6c1.png)

I’m not sure if this answers your question but I thought it is nice to know

---

<div class="post-metadata">

**Author:** ![bibbi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@bibbi](https://community.thunkable.com/u/bibbi)\
**Post date:** [November 22, 2022, 11:30pm UTC](https://community.thunkable.com/t/how-to-create-a-cloud-variable-listener-for-a-sub-bucket/2140238/3 "2022-11-22T23:30:15Z")

</div>

hi

I believe that my problem remains with the cloud variables I cannot detect the change of state of a lower node with this block

 ![Capture d’écran 2022-11-23 à 00.35.34](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/9/792bb50ee1272c47f36b94e627287574862646b1.png)

I have a “house” node which has a **variable** number of “piece” sub-elements  
when I modify the “kitchen” sub-elements how do I know that it is “kitchen” and not “living room”?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 23, 2022, 12:32pm UTC](https://community.thunkable.com/t/how-to-create-a-cloud-variable-listener-for-a-sub-bucket/2140238/4 "2022-11-23T12:32:26Z")

</div>

OK,  
You have two options here

The more straight forward option is to use a timer to read the key required and check if the value stored has changed. Firebase allows up to (200,000 per second for paid plans or 100 per second for free plan)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/7/b76cb15e36a42fb3b14d09cc3f4cc44b0ed42b95.png)  
[database limits](https://firebase.google.com/docs/database/usage/limits#global)

I believe 10 or 20 times per second is a sufficient practical limit.

The other way is to create a bucket (monitoring key) that you will store any changes you make in your database along with the desired key.

With this, you can use the `when initializes or change` block to point to the monitoring key which will fire every time you update it whn you change anything in your database.

This can be done in the app itself or using a Firebase database function in the database.

---

<div class="post-metadata">

**Author:** ![bibbi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@bibbi](https://community.thunkable.com/u/bibbi)\
**Post date:** [November 23, 2022, 5:49pm UTC](https://community.thunkable.com/t/how-to-create-a-cloud-variable-listener-for-a-sub-bucket/2140238/5 "2022-11-23T17:49:10Z")

</div>

hi

it turns out that I have already tried with a timer but it flashes the dvl corresponding to the bucket that I am monitoring  
in your second proposal, what bothers me is that my buckets are created dynamically and are used interchangeably and I do not see in the block above how to have it modified so that it corresponds to the modified bucket  
I had to leave all my energy on the clones 😔

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [February 21, 2023, 5:49pm UTC](https://community.thunkable.com/t/how-to-create-a-cloud-variable-listener-for-a-sub-bucket/2140238/6 "2023-02-21T17:49:55Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
