How to decrease DB rendering time? Takes 1-2 seconds to update

Hello! I’m building a purchases list, and using AppGyver Cloud Storage to repeat the list. But the list takes 1-2 seconds to add an item. The same with delete, when I press a list-assosiated cross.

Can I instantly see changes the list? I’m ok with some backend delay, but the app knows that I added an item, and there’s no need in backed to draw that quickly.

Please see the video demo: https://youtu.be/tXzw9OPokQk

Hi,

After the component tap event for that button, you could use Set data variable flow function and manually add the new entry to the data variable you have for the list of items. This way the list of items gets updated and displayed immediately, while the actual backend operations are still happening. When the database actually gets updated and the list is also updated, there shouldn’t be any visible difference to the user. Let me know if this helps!

2 Likes

Thanks! I tried and I found that I don’t understand, how tu update data variably (type Collection) with …with what? I need to put something in the “Record collection” field. As it is the “Set data variable” flow node, this must be some another data collection variable to set equal to …

Hi!

So the value will be the same list of records that is currently in the data variable, plus the newly created item. You can do this with the help of a formula, just change the binding of the Record Collection to formula, and check out the formula function WITH_ITEM

I put the formula like that
WITH_ITEM(data.PurchasesCollection, [{done:data.Purchases_NewRecord.done, id:data.PurchasesCollection.count, name:data.Purchases_NewRecord.name,position:data.Purchases_NewRecord.position}])

It creates a list item, but empty, and then after a delay adds the name. I think, something’s wring with this formula and the list waits for the Database responce to “fill” the new record

I think the issue lies in that you have put the new record information in a list with the brackets [ ]. Try removing those so you’ll only have:

WITH_ITEM(data.PurchasesCollection, {done:data.Purchases_NewRecord.done, id:data.PurchasesCollection.count, name:data.Purchases_NewRecord.name,position:data.Purchases_NewRecord.position})

It has a set of validation errors, but at least it populates the list immediately. Thank you

Great that it works! But hmm about the errors, I think one issue could be the id property. The syntax .count does not work in formulas, the corresponding function would be COUNT(), which however returns a number type value when I assume id wants a text type value. Any way it doesn’t matter as this item is eventually replaced with the actually created item, but if you want to get those warning out you can try id:GENERATE_UUID()

Thank you so much! Works like charm.

Let me ask other question, nobody helped me here. Is it possible to address to a visual component by name or it to get it height, for example? Like getComponentByID(id).height or sort of?

Getting a component’s style properties is. not currently possible unfortunately :confused: But you could submit a feature request for it here. If you want to use the height value in many places, I would suggest you set the height value in an app variable (as a number) and then use that in the style properties of different components.

1 Like

Thank you. Yes, I just added the feature request.

1 Like