RealtimeDB DataChanged Refresh Issue when reopen screen

Thank you for the detailed explanation.

I can tell you that will not work for two reasons.

1- Starts and Opens
These names are confusing, actually they work different that what people think. One thing for sure that if you go back to your screen using a button which uses the Navigate to screen block then both Starts and Opens will execute. the only time the Starts will not execute is when you go back to the screen using the screen swipe gesture.
To overcome this issue create an app variable for example Listener Active and set it to FALSE whenever you have you screen active first check if this variable is false to to execute the listener block and immediately set this variable to TRUE. This way you will avoid adding the listener multiple times.

2- Data from the listener should be saved to variables
Thunkable does not allow accessing the components of one screen from another screen. So if you are in screen 2 and the DataChanged block is in screen 1 it will execute when the data is changed in Firebase but it will fail to update labels in screen 1 because you are currently using screen 2.
The remedy to this is to save the information into a variable and when the screen becomes active, you update the labels from the variable that was changed by the DataChanged block.

Hope you find it clear.

1 Like