Greetings ! I’m building an app with firebase but I encountered a problem and I need some help to discover the reason it happens.
The app contains 8 screens, some screens interact with firebase, some don’t.
When i’m currently viewing the blocks of a screen (which interact with firebase) and run the app on my android phone, everything runs fine.
When I’m currently viewing the blocks of a screen (wich do not interact with firebase) and run the app on the same phone, whitout any modification to the blocks / design, some of my firebase get blocks wont run.
Based on this observation I’d say it’s not a block-logic issue, since it does run well sometime, my guess is a memory error or a compilation error.
Any help would be appreciated
Ahh . I have seen this behaviour. I am wondering if something wonky is going on.
What I do is the following:
- Make sure all variables that are actions dependent, are cleared on a new action.
- Look at the blocks, sometimes you have an unintended nest, or you intend a nest and it is not there. Nest is when the performance of one action is related to, or event conditional (with the right blocks) on another.
- Setup some debug variables. Do NOT ignore the ERROR data. Dump it somewhere so you can see it while you debug.
- Use the visible command for error flags. On status /= 200 make WARNING visible.
Debugging Trick
Start with that to see where the data is, and then it will make it easier to see where it is breaking.
BTW . at the end of the day you WILL have more management and debug blocks then control. Probably 2 or 3 to 1.
Thank you for your tips Cian_O_Sullivan, while debuging I did not encounter any error linked to my firebase get blocks, nor were my variable set to unexpected values.
I believe my code is badly structured : the culprit screen is a character creation menu, for each sub-categories of it (race, realm, profession) there are 12ish item and while cycling through each of them a firebase get command is used to set the item description and title.
I will modify the blocks so a local database get all the necessary data from firebase during a loading screen.
I wonder what is the ideal way to store a large amount of reference data (about 100 pages) in the app, any suggestion ?
Elygius
What format is the data in?
For data management of on device versus off device, it is not an all or nothing. You can spool anticipated queries. For example lets say you have 12 character traits, What you do is load the first 4, and then once the person has made their 2nd out of four choices, you load the next four, then when they have finished the first 6m, you load the next four.
Its a form of what we call dynamic pagination. You are calling in anticipated data, not everything, and not waiting for call on demand. So you are turning your 100 pages into pages that would be consumed in some form of chunk level. Then calling when there is a reasonable probability they may be needed.
Does that help?
The data is stored as strings in Firebase.
I just finished my attempt with a loading screen and a get command to load all the data in the local database but I am facing the same problem once again. I believe the issue is the app does not wait for the result of the get command before jumping to the next block, leading to missing data.
Is there a way to confirm the data has been received and stored succesfully ?
I was not aware of dynamic pagination but it does make a lot of sense, I’ll keept that in mind for my next attempt.
Thank you again for your help
Per your question,
I think you should explore the Function blocks (orange), You can do an If, Or, Else. You can set that up to wait for a status from the request you get, or some other detail. You can also add a “pause” . (which is not production quality, however it will give you the pause you need until you figure a better way). The blocks in X are limited relative to classic, so a little bit of kludgy code might just do it. We al use them for event handlers and error handling.
That help?
I managed to find the bug !! Turns out when I’m editing page A and live test, my list start iterating from index 0 and when I’m editing page B and live test, my page A list start iterating from 1 so I was missing the first value of each list.
I do have an other question, should I initialize all my variable on my first screen or should I initialize them on the screen it is used ?
Your posts were quite helpfull in my situation, thank you.
1 Like
If the variables will be used across screens, you should initialize as soon as possible. It is also easier to manage. If a variable will be used multiple times for different purposes on different screens, then set and scrub it as needed.
If a variable is only needed on Screen3, initialize on Screen3 Open.
Really this is about management and scalability. The rule of building, make it work, make it work well, make it work fast and well, and make it look good.
Clone your app and reorganize yourself when you can. I hope that helps.
1 Like