Is it necessary to assign a cloud variable in a local variable

A somewhat stupid question.

When you display a cloud variable several times on a page, is it better to display the cloud variable directly or to assign this cloud variable to a local variable and after display the local variable.

The object of this question is to optimize the firebase accesses of my app.

1 Like

This is not stupid at all. Actually this is a smart one.

Cloud variables retrieve information from Firebase RTDB and therefore you do not want to overkill the database by unnecessary calls. In the other hand, if you are displaying the same value then you are killing the app speed by retrieving the same value again and again from the database over the internet.

For the above two reasons it is advisable to retrieve the value once using a cloud variable then assign the value to an app variable to use it as and when required in the app.

2 Likes

Thanks a lot Muneer. It is actually the way I worked with cloud variables. With you answeard, I know I will continue in this way.

2 Likes