Replace GET or SAVE Blocks with cloud variables

I just discovered a VERY simple and fast way to get and set Firebase data without using the GET or SAVE blocks (which has all sorts of asynchronous issues).

The 2 any button click blocks below return the same data. Just put the GET block KEY variable into the CLOUD variable name and PRESTO. You have a synchronous call to firebase!

Similarly, you can set data anywhere in the JSON Hierarchy using cloud variables. Both of the examples below update Firebase, but the CLOUD based solution does not have the timing issues of the SAVE Block

7 Likes

Hey!
Nice one, it’s really good and will help me retrieve DB information without so much code.
I know that this isn’t relevant, but if you know all the text that you are putting in the join block (that means there is no ‘get text’ or variable or holder for text you don’t know) then why did you use the join block? If the join block has some use, please share it here. I would love to know that because one of my favorite blocks is 'join’:grinning:

1 Like

Code clarity is one advantage

@codeswept,

In this post the joins are for illustrative purposes. As @muneer says, readability is key, especially for community posts.

Happy Thunking!

3 Likes

Oh, ok. Thanks.

1 Like

@drted i am not getting what is this?

it is a comparison of 2 ways to get data from a Firebase Realtime Database.

2 Likes

what a great MAN!!

Thank you so much for sharing that you are too strong.

I just got on Thunkable I was on Kodular before and I had a hell of a problem with firebase and loops.

You solved my problem, how did you find it?

I’d be curious to know. You literally just hacked Thunkable wow I’m so happy.

I re-publish your example for beginners. It took me 5 min before I understood.07ea4eeae6e7f789c1276881d1f5a8d3

2 Likes

What kind of sorcery is this?!

image

3 Likes

Lucky guess :wink:

I’m surprised that the Thunkable team has not added this conversion to the official documentation. @domhnallohanlon has suggested in other posts that the goal is for users to move away from get and save, but the docs don’t show you can do this

8 Likes

actually cloud variables are connected to firebase itself

and thanks @drted

@drted have you found a way to catch errors when using cloud variables vs. the Realtime DB purple blocks?

1 Like

The error would typically be that the key doesn’t exist, right? I feel like I did try to figure out what value is returned by an invalid key but I can’t remember what it was. Easy enough to test and if it gives a specific value, to then check for that.

Well… it could be a permissions issue. So for example, how would you catch the return code (error) for the following?

1 Like

Good point. I’m not sure.

Hmmm… well, without error control, using cloud variables is kind-a-pointless, unless of course you are super confident about the successful execution of the operations. To be honest, I don’t have much experience with the Realtime DB so maybe I will find the answer as I dig deeper into the rabbit hole.

Thanks
K

1 Like

I guess my take on it is that I’m using a Firebase data set that I created using Thunkable so I’m always going to know how the data is structured and I’ll always have permission to access it. But I can see how that wouldn’t necessarily be the case for everyone.

1 Like

This seems like a Gr8 idea! I am testing it to see does it solve my problem!

Yes, you are right! I have heard about this.

Hello, what is all of this for exactly?

Also, would you happen to know how to use two way authentication with firebase to log in? I saw the document explanation for it within the docs section of thunkable, but it isn’t working correctly for me. I’m new to this and need all the help I can get!

1 Like