# android

Remon Shehata

06/06/2020, 10:52 PM
Hello guys, I have a tricky question 😄 I have a function that adds a `User`object to firebase. and of course, it's a callback function. now what I want to add is to add a list of `User`s. a simple for loop won't do the trick since the callback function runs on a background thread. I thought of creating a function the returns the next user from the list. then I can use recursion and on the callback
I can call the same function again and pass in the next user. I think this would work but I am not sure it's the optimal way to do this..any ideas?

Adam Powell

06/06/2020, 11:11 PM
Turn the add operation into a suspend function and then you can use a simple for loop 🙂
👍 1

Remon Shehata

06/06/2020, 11:30 PM
I have never used it before. now it's the time to learn about it I guess.
one last question. if the add operation itself has many callbacks because it adds different documents(4 docs with collection inside them). each one after the other. it's working but it takes time. any suggestion to improve it?
google 1