Clone Component based on length of list

Hi All,

I’m using the new clone block in my app, when the screen opens I pull data back from firebase and put it in a list, I then clone blocks to hold that data, does anybody know how to clone only new items from firebase, whenever the screen opens it just keeps cloning everything

Hi

What is the difference between new elements and old ones? If there is such a difference, then using the conditional block you can create an algorithm for copying only new components.

3 Likes

like make a comparison from the lenght of the old list with the lenght of the new list and if it’s longer only get the difference elements?

1 Like

Thank you for your responses, the difference in the components will be the different data being pulled from firebase,

I did think of getting the length of the list and then if the length changes using the clone component. However - even if the list doesn’t change I will still need to use the clone component, and so everytime I open the screen it is still recloning,

Does anybody have any block examples on this?

I don’t understand your problem and what you want your app to do.

If you are saying that the appa clones ALL the list components everytime you open the screen, you need to use the block named ’ when screen STARTS’, and not opens, that will clone the list only the first time it’s opened and not everytime

Hi Max,

Thank you for your comment, however this wouldn’t work because I want the screen to show all the latest entries when the screen opens, if I do it just on screen starts, and then a new entry is available, it won’t show it unless the user exits and restarts the app, in this case I have used a measure to find the length of the list and if variable is greater than length of list I will add it,

Thank you for your help

First: If the data comes from firebase, there is the “when data changes” block that will trigger only if data has changed, in that case you could add the cloned… Ok I think I get your problem and in any case you could delete all the already cloned blocks and clone them from the start whenever a new data is added/changed.

I think you could create a more complex solution to only add the new entries to the already cloned ones, but to be honest, I have to work on my app and can’t really think too much about yours ^^

Hope this helped a little