Disclaimer: my app works correctly right now, this is a post purely about increase performance and maintan code best practices.
I have a few collections in my app. A couple of them I need to be true reactive, but many others follow this pattern:
1)Collection can be updated by a very small set of users in a specific admin area of my app
2)Collection needs to be fetched as read-only, immutable data for the majority of users in the main app
So far, to facilitate the updates in point 1, I treated all collections as pub/sub.
However as I read around pub/sub are also one of the source of performance issues in Meteor apps and because I don’t really need reactivity for the majority of users, I would hope to be able to do something else.
I understand that I could expose the same data that is in the publications in some methods, and make users of point 2) use the methods instead.
But if I go this way, I’ll need to share permission checks, and fetching logic both in the publications (for users 1) and methods (for users 2). Moreover I’ll need to make sure I don’t call the methods on reloads but always check myself if the client already has the data.
Is there any more elegant way to handle this?
Ideal I would love to be able to pass some option to subscribe to notify the server to just send the data, without creating a real subscription, so I could also reuse the caching logic that subscription have.