How do I store a value that I got from a firebase db into a global variable?

I stored values in the firedb, 4 tags with 4 values and i got them using getvalue now I want to store these values to a global variable

how to do that using when firedb got variable

thank you

Use the gotValue event block

When each of those 4 requests' tag and value arrives, you need to store them somewhere.

There are several options you could pursue:

  • Devote 4 named global variables (radius, developpass, etc.) to those tag/values, and code an if/then/elseif ladder to check for each tag and store the incoming value into that variable.
  • Make one empty global dictionary and store each incoming firebase tag/value into a corresponding key/value in that dictionary
  • Store the incoming Firebase data in TinyDB, tag for tag, value for value.

Since you probably want all of those 4 values to arrive before proceeding further in your app, you would need to clear those 4 values before the first read request, and check all 4 after each value arrives.

Another alternative would be to ask for the entire bucket where they live, and deal with the incoming dictionary.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.