Problem repeating item in list viewer


When I do this :

It gives me this :

Note that here the label shows the “name” variable but it in the listviewer it doesn’t show. May you tell me why please ? Thanks !

By the way your solution worked except for this ! Thanks a lot :slight_smile:

please change the green null-block to a red textblock with “null”

1 Like

@User81 it doesn’t change anything. Please see the upper post where I point out the fact that the value isn’t null because it is needed for the next step and the next step is working fine. So I don’t think the “null” was the issue.

Thank you for helping me! Looking forward to your reply !

I cannot help you. using loops and local storage at the same time seems impossible for thunkable. please save the list of friends as a list to text and get it from there.

good luck, bye

1 Like

@Mark Is it really impossible to use localstorage in loops ?

@User81 Can you explain this please ?

Thank you :blush:

It’s not impossible, but it can lead to unexpected results in certain circumstances. The basic issue is that 'LocalStorage.Get' (and Set) is currently an asynchronous operation, meaning that it is executed more-or-less at the same time as the blocks that come after it - including blocks that come after it in a loop. That’s we we have the 'then do' slots, which tell the 'LocalStorage.Get' what to do once it gets a result.

This affects your loop in that all the 'Users.Get' blocks will execute at more or less the same time. Moreover, they will all happen at more or less the same time as your loop is incrementing the 'Friends' variable! So the value of 'Friends' with the 'Users.Get' blocks could be just about any value between 1-25 in any of the 'Users.Get' blocks.

I wrote a little more about this sort of problem in Asynchronous Blocks within Loops. It also contains a workaround for how to deal with such issues.

Also note that we are thinking about possible solutions to this issue, but have no timetable yet.

I’ll also just note that @User81 is correct that you need test for the string “null” rather than the using the green null-block. I know it’s confusing ;-( . He’s also right that it would be easier if you could just save and get the entire list at once. Then you can loop over the list and have fewer problems.



Ok thanks to both of you, I’ll look into it and come back if I have any more questions.

Have a nice day :slight_smile:

Hey @Mark ! Your tutorial stands for saving the value if I’m not wrong, but I just want to gather the information and here the realtimeDB is not at cause because the loop gathers the information from RealtimeDB with the use of the “name” variable, but still isn’t able to show this variable in the final list.


I used a workaround that wasn’t listed in your topic but maybe you could add it :blush: ?
Please check the attached screenshot to see the few more problems I am having now.

UPDATE : The not showing value issue was fixed by inserting the set textitems into the userFB then do

Thank you for helping me !

The fact that my tutorial deals with saving and not just getting values is not really relevant. The relevant part is converting the loop to a recursive function (i.e. the ‘AsynchLoop’ function in my example). However, I can understand how it might not be obvious how to adapt that function to your case.

Your workaround to wait a second is a little too hacky for my taste. For one, if you’re looping over a lot of items the delay will be considerable. Also, you don’t really know exactly how long to wait. That said, I am glad that it works for you!

For the ListViewer issue you mention, if you have too many items in the list to fit within the height of the ListViewer, that’s the expected behavior. You might need to adjust the height of your ListViewer.

For the ordering problem, it looks like your TextItems list is not numeric, i.e. does not simply contain numbers. Unfortunately, switching to alphabetic sorting will like not work either since I assume that you want to sort by score. To do the sorting you want you’ll have to do something more complicated and sort them in some separate function where you parse the text items to extract the score.

If you do as @User81 suggested and keep things in lists you could potentially use the list sorting blocks.


1 Like

Could you help me set up this / give me a block example of how I should set up this in my project because you’re right, the delays can become very huge :confused:

(I can’t really understand what is an AsynchLoop even after looking at your tutorialand how to insert it or adapt it to my example (what should I replace or change, etc.) but I’m really looking forward to learn how to use this and make my apps more reponsive !)

I tried this but I for sure mistaked somewhere, may you guide me please ? :blush:
Thanks for you help @Mark !

let me try to give you a picture of loops, that are asynchronous (“async”):

you have ten people in a row in front of you. But instead of fast counting the people really fast from left to the right, you tell every one really fast: bring me a beer (:beer::grin:). Now you have told everyone and do other things, while the people are running to find a beer. from now on you have lost control over when they will come back with beer.

everytime, one of the people comes back with beer, one then-do-section is triggered.

what can you do to bring some order to this issue:

  1. waiting: you could use the timer component ore the wait for X seconds component and estimate a time, when everybody is back. (I would not recommend that)

  2. you count, how many of them have returned yet and when the last one comes back (with beer of course), you do your next operations. (see example below)

one last thing: in the project you showed us in your posts you want to get a value and then use this value to get another value: please do not do this, because it is complicated enough to do one async loop.

1 Like

I don’t get it but got the fact that you had no time to get this personnal. Is there someone kind enough who’d see no problem taking some time to explain me in private how tu use asynch blocks please ?

Thank you !

hey @AcrobatEpee,

I thank you for being a vivid part of the thunkable community. And in fact I really took my personal time for you (stopped working on my projects to build iOS projects to share and making screenshots and trying to understand your problem and explaining)

Sorry for not sharing my personal mobile phone number with you. Maybe you will find someone who can do that and I hope you will share your solution with the other lovely members of the community.

The fruits you want to pick are right in front of you. Either you use the recursive design of @Mark , which does not use the loop components (repeat…times, from-1-to-10-do…, while…do) or you use my design which I would describe with sending all orders on one instance and then wait for the last one to return (if-length of returns=length of orders->then do…)


1 Like

Of course I will share with my community when I find the issue. I’m working really hard on understanding and I’m trying to find somebody to help me fast up a bit. I’m totally thankful to you and Mark don’t mistake on that one I was being thankful not meanful, sorry on how you understood this one :confused:

Much love to all thunkers helping daily on this forum :smiling_face_with_three_hearts:

Nice day :slight_smile:

Hey @Mark and @User81, I made another type of Asynch loop but this one doesn’t seem to work :


…Is this part :


In this block from Mark’s tutorial :


essential to make it work ? Thanks !

Yes, you need some 'if' block controlling the function call there in order to make sure that there is a way to end the loop. Otherwise, you get something called ‘infinite recursion’ .

1 Like

But If I don’t know how many times I want it to repeat, how should I do ?

I should have looked more closely at your blocks. You do, in fact, have an 'if else' block that is controlling when to end the recursion/loop. It is the one where you test for value != "null". I suspect, though, that what you really want is just an 'if block' which calls 'singleuser' , increments the 'store' value as you already do and calls 'do somethings' as you already do. That will loop around as long as value != "null" and will stop looping when value = "null".

One thing to note, though, is that I suspect that you want to pass a parameter or two your singleuser function, such as value and maybe store, otherwise it might be difficult for singleuser to figure out what to do.


1 Like

The thing is that the singleuser function is independant and ran only once.

Update : Is this what you were suggesting ?

Thanks for your help ! :slight_smile:

Hey @Mark !

I think you made a small mistake, actually it will loop as long as the value is equal to null :slight_smile:

But can you find why it is not working then ? Because with what you said, all seems to be fine no ? Maybe I am having the same problem as the same time where I have to wait several days for my app to get functionnal by itself ?

Update :

This made it work ! Thanks again for your precious help ! Awesome day ! :slight_smile: