The main screen of my app has infinite scroll. I use meteor methods for the majority of the document’s properties, but I subscribe to the reactive properties of the documents retrieved from the meteor method.
I accomplish this roughly as follows:
// ===== CLIENT =======
let docs = [];
let page = 0;
let subHandles = [];
loadMore() { // loads 10 more documents
Meteor.call('getMore', { page }, (err, newDocs = []) => {
const newDocIds = newDocs.map(({ _id }) => _id);
docs = docs.concat(newDocs)
subHandles.push(Meteor.subscribe('reactiveDataOnDocs', newDocIds));
page += 1;
});
}
// ===== SERVER =======
Meteor.publish('reactiveDataOnDocs', (docIds) => {
return Documents.find({ _id: { $in: docIds } }, { fields: { reactiveProp: 1 });
});
Not all users see the same feed of documents. For example, user1 may fetch documents A, B, C, D, E, and user2 may fetch A, C, D, F, G.
Questions:
- Does it add more overhead to subscribe to each document individually? (e.g. does ten subscriptions for ten different documents use more memory than one subscriptions for those same ten documents)
- If user1 subscribes to documents [A, B, C, D, E], and user2 subscribes to [A, C, D, F, G], are A, C, D in memory once or twice?
I apologize if I’m not explaining this well, but I will clarify as needed