0

I am working on a Meteor app that requires a pagination (infinite scrolling). If the user scrolls to the bottom, I pull the next chunk of data by Collection.find({"offset": {$gte: currentOffset}}, {limit: limit}). The problem with this approach is that the previous documents are no longer available after this. I can delete offsets to keep the old one but it slows down the app after pulling over 1000 entries. I use publish/subscribe with komposer containers. Is there a way to keep the previous collections reactively on top of the new chuck using limit and offset? Thanks in advance.

user2646559
  • 71
  • 1
  • 8
  • Have you taken a look at [this](https://www.discovermeteor.com/blog/template-level-subscriptions/)? – blueren Nov 26 '16 at 09:59
  • Hey. Thanks for the suggestion. I looked at that article and as you can see there is no offset for pulling data, meaning it slows down after pulling big chunk of data. – user2646559 Nov 26 '16 at 17:13

1 Answers1

0

You could use kadirahq/subs-manager instead of the default Meteor.subscribe to subscribe for data. This package will cache your subscriptions and all their data to improve the app performance.

But keep in mind that even when using this package if you send to much data to client, say more than a thousand documents, your app will end up slow and slow because it has to keep all documents in memory to watch for their changes.

Therefore you should limit the maxium number of documents to publish to client (IMO, 300-400 should be fine). If you need more, consider using other way to do pagination.

kkkkkkk
  • 6,848
  • 2
  • 13
  • 27
  • Hey. Thanks for the reply. I tried it but I didn't feel noticeable performance increase. The app itself has a pretty nice performance without this scrolling > 1000 entries. – user2646559 Nov 26 '16 at 17:08