0

I'm using Firebase for my iOS application and I'm having trouble implement infinite scroll and filtering data together.

What I need to do is:

  1. Display items with order/filter on multiple property (location, category, status . . .)
  2. Implement infinite scroll when the user scrolled to bottom of the screen.

I tried to think about some solutions:

  1. The first, I think that I'll query the data with the necessary conditions then limit the number of records by use queryLimitedToFirst(N), and increase N when need to load the next items. But because Firebase can only filter on one property at a time and it's also a waste to reload data. So, I was thinking about the second solution.

  2. As approaches are suggested from Frank van Puffelen (Query based on multiple where clauses in firebase):

    filter most on the server, do the rest on the client

    Yes, exactly like that. I'll execute queryOrderedByKey, queryStartingAtValue, queryEndingAtValue to implement infinite scroll, pull down the remaining data and filter that on client. But there is one problem that is I would not have enough items to display for the user if execute filter on the client.

    For example: each time run the query, I receive 10 items. After data filtering process on the client, I just left 5 (can be 0) items meet the conditions to display to the user.

    I don't want this because user may think there is a problem

Can I please get some pointers on this? If I didn't structured the data properly, can I also get some tips there?

Anh Pham
  • 2,108
  • 9
  • 18
  • 29
  • You've seen what is considered the default answer for this problem. Unless you've tried something and are having trouble to make this work (in which case: post what you've tried) this question is either a duplicate or off-topic. – Frank van Puffelen Jul 04 '16 at 20:31
  • @FrankvanPuffelen I was looking for some answer. But most of them is to solve the problem either "Query based on multiple where clauses in Firebase" or "Infinite scroll in Firebase". No, I don't solve two separate problems, I want to ask how to solve the problem when doing these two things together. – Anh Pham Jul 05 '16 at 01:04

0 Answers0