I have resource heavy helper which I should run on page as rare as possible.
The helper contains a reactive variable: Meteor.user().profile.gender
When I update denormalized field Meteor.user().statsCache.hits, not touching Meteor.user().profile.gender my helper reactively updates without any need, lagging UI. I understand it is because subscription updates and sends a new User document to client.
But how can I prevent helper to rerun if its particular reactive document parameter doesn’t change?
I thought about somehow splitting it to 2 different subscriptions, but I’m not sure if this helps as server may still push change?
Meteor.user() is actually a findOne on the Meteor.users-collection, so if you directly use this collection, you can control the included fields in the result:
This query will only invalidate when profile changes. (Note that you cannot further control reactivity for nested fields like profile.gender as far as i remember, so that you could distinguish e.g. between profile.gender and profile.fullname).