Whenever you have a huge set of data, it helps to cut down on the amount of data you fetch from the Cloud. The technique which we'll use is to break down our fetches into small batches which is called pagination. It turns out this is rather simple to perform with the available APIs in Firestore. Let's see how this is implemented in today's lesson.

Comments (10)
Robin Bindewald
4 years ago
Hey Brian, how does the Pagination of Tinder is working. They have for sure also pagination but how the handle the new added Users and the Users which have already been voted on. I can not really wrap my Head around this. Are they Filtering with a List (for each User) which Users are already been voted on or is there a more advanced technique. I really like to hear your approach on that :)
jiarongkoh
4 years ago
Hi Brian, I have read that it is a good practice to keep UI related elements on the main thread, and therefore would think that it is better to place the huds inside a dispatchQueue.main.async(). I noticed that you did not practice this widely in this tutorial, so would like to hear your opinion on this. Is it because it's not necessary? Or omitted for simplicity of the tutorial.
Brian Voong
4 years ago
flashtrend
4 years ago
Hey Brian! Loving the videos so far! I was wondering how we can paginate without a refresh button, so that as the user is swiping through the cards more cards will get loaded as they near the end ?
Brian Voong
4 years ago
Tube
4 years ago
Shouldn't we reuse Cards from a pool?
Brian Voong
4 years ago
Dariusd
4 years ago
Although I added: "cardsDeckView.sendSubviewToBack(cardview)" I still experience flickering. Am I the only one experience that problem? Any solutions/suggestions?
Igor Tkach
4 years ago
Yes no flickering for me! Check your code!
Cinquain
4 years ago
That video was fire! Will definitely visit the pagination page on Firebase documentation.
Nikhil Nangia
4 years ago
I really could not understand the usage for "cardsDeckView.sendSubviewToBack(cardview)", please a brief bit more. + the sessions are becoming more of tool oriented intents to lose interest
majdjamaleddine@gmail.com
3 years ago
Hi Brian, I'm running into a little problem. I am able to fetch all users from Firestore, but when I call the .order/.limit methods it only works for the first time when loading the app. When hitting refresh it fetches only 1 specific user is fetched, I deleted this user and now nothing is being fetched when hitting refresh. I appreciate having ur thoughts on what might be the problem provided that I copied and paste it your query code and still got the same result. Thanks.
MIkeb
3 years ago
Does anyone have any code snippet that will re paginate after the limit is reached? so if your limit is five cards, it will re-run the query automatically after you swipe the last card? I cant seem to find any videos or info on stackoverflow regarding how to do this in swift for firestore....
Brian Voong
3 years ago
MIkeb
3 years ago
solution works - huge help...thanks so much!
antoinenei
3 years ago
For those implementing this at the end of the project, add if topCardView == nil{ fetchUsersFromFirestore() } at the end of the performSwipeAnimation in the HomeController. Keep in mind that this will only bring back what you have already swiped through.
bliu521
3 years ago
How do you paginate so that the next time you use the app it will show you people based on where you left off and not show you the people you already swiped?
Brian Voong
3 years ago
bliu521
3 years ago
Thank you Brian!
HELP & SUPPORT