Is there a quicker way to populate lists?
I have a list in my app that I want to populate with items that are drawing information from various different locations but I feel like it takes a while to populate each item. I would like it so that it is done within a couple of seconds of screen load but it is taking about 10 seconds.
I think it might be due to how I am populating the lists but just wanted to check my theory.
At present I have the app looking into my realtime database for each bit of info I want for each item (I am using a “for each item” block). The app then adds the info which I have defined by means of a “get property of object” chain. Then the app joins a few variables together to display the information I want. But would it be quicker to use a json script? Rather than individual locations for each piece of information?
My understanding on what JSON is exactly is improving but I might be still well off the mark.
Each use of a cloud variable is a separate call to Firebase to get that value. So in your code, you’re using cloud variables once to define the loop list and then four times within each loop. So, for example, a list of 20 items will call Firebase a total of 81 times. So yes, I would expect that to be slow.
It would be much faster to get the entire Firebase data that you need and assign it to an app variable so that you are just accessing a local app variable each time the loop iterates.
That does make sense. So would it be better to assign a JSON script to a variable then have my loop assign that JSON script to “app variable J”, then search for the specific data in that local variable?
That leads to a connected question; I am thinking of two ways to complete that what you’re saying.
I have a folder path on my realtime database that looks like this - "leagues/participants/json/j
Where j is a reference to a specific item (let’s call it CARREF). Then I hold a JSON script in this folder path related to a specific item.
or
I have the JSON for all items in one location such as “leagues/participants/json” and all items are part of the same JSON script.
Which would you think is better for large amounts of data (which I hope this to be at some point)?
I know you can create lists within JSON but how would I then differentiate between different items within 1 JSON?
I appreciate your patience and I understand this must be simple for some but I am learning all from fresh.
Just tested this and it certainly has sped things up hugely. Thankyou. Shall I create a new thread for my related question or can you answer in this thread?