Tonight I wondered why MIT App Inventor (which I tried before Thunkable) uses two different blocks to read data from a database: “GetValue” (call) and “GotValue” (receive). Maybe to give the app the time to receive the requested data? Thunkable only uses one block (Get)… so I tried to insert a pause before evaluating the answer.
2. the ‘then do’ path This refers to the “then do” section of the purple method block.
These blocks occur asynchronously. This means that they work on their own time. Another way to think about it is, The app is now executing any code in this section plus what’s below the purple block at the same time.
That said if blocks below the method block require the code from within the method block, and your app moves too quick or the data/computations/code execution takes too long in the asynchronous “then do” section,. In other words, the app code tries to use the results of the ‘then do’ before that data is ready.
Does this make sense?
you could also make something like this. you’d put the blocks in the green box, minus the delay, below the if/'then block in the ‘then do’ section of the realtimeDB Get Call
unfortunately what you suggest me to do was my first choice, which is the first way I tried to create the selection of stores that have a given property. But it does not work. I tried and tried again for three days without getting the result, but what’s worse is that the errors were sometimes different and random, not reproducible. And this is very worrying. Thanks anyway for your help
I know this is a bit late, but I came up with a solution to both propblems: how to access a firebase database and how to extract from a JSON hierarchy.
Notice that loading is a two step process 1) Use the SAVE block to initilize the object on firebase (weird, but necessary). Then you can reference the object using the set block to populate the variable. Now the firebase data is accessible using thunkable VARIABLE blocks. No need to use the Get and save blocks.
You can access the data using the variable blocks, but that doesn’t address how to drill down deep into the hierarchy. The GetProperty function resolves that issue. The KeyPath parameter works just like in MIT App Inventory. Object are specified using the name, and list are accessed using the position (0 is the first position). The GetProperty function works on firebase and local JSON objects.
I was having a little trouble following what you were trying to do with your blocks. I added a few block for the LONG CLICK events that save data to a cloud variable then retrieve it into the list control. I Think that is what you were trying to do.
You might also try getting the screen to work using either APP or STORED variables, then move them to the cloud. That way you can determine if the problem is with the cloud/firebase connection or your other blocks.
Thanks a lot for your reply. I did try exactly the way you said, but its not working for me. After long click of the Done as well as Back buttons, nothing happens.
I am able to read data into Firebase from Text_MS1 & Text_MS2 and also able to display data into app from Firebase however I only get the last entry displayed and am not able to display the entire list. PFA the Firebase sample data for reference.
Thanks again for reply. Have attached 3 screen shots.
Design - The design of the app Block 1 - Blocks where I have initiated variables, defined how to enter text and then how to write it to Realtime DB. I am entering Milestone No. in Text_MS1 and Milestone details in Text_MS2 Block 3 - Blocks where I am trying to retrieve all the Milestone nos. and Milestone details after clicking Back button
I have seen and experienced the same problem. Many people have this issue. The problem is that the Realtime_DB1 Get block is asynchronous. If you want to use it more than once, you must tell Thunkable to wait until it is finished.
There are many possible solutions. Below is my current favorite solution.
Create a Get Cloud Property function EXACTLY as show. You can then use this function anywhere you would otherwise use the Realtime_DB1 Get block as I show in the example “Any Button” click event. This example uses a list parameter called “KeyPath” to map the JSON key hierarchy. The Return values is whatever it finds at the end of the path. For your example, it returns the value in Title.
Please note that DVL (Data Viewer List) requires a direct connection to a table and cannot be used with Firebase directly.
For the example of the vehicles, if you want the data displayed in a DVL instead of the List Viewer then you will need a Local Data Source. You will use a list variable to store the values from Firebase and then you will loop through all the values in the list and save the values in the Local Data Source table you created. This table is connected with the DVL and the data will show in the screen this way.