This is very very odd. The code in question:
Template.featuredProds.onCreated(function () {
this.autorun(() => {
console.log('limit products to:', Session.get('limitProductsTo'));
this.subscribe('products', Session.get('limitProductsTo'), function () {
console.log('setting prod count to', Products.find().count());
Session.set('products/count', Products.find().count());
});
Session.set('products/loaded', false);
});
});
What’s happening when the page loads:
I see a ‘limit products to: undefined’ at first, but then immediately after:
limit products to: Object {slug: Object} slug: Object $in: Array[5]
setting prod count to 8
So even though it just subscribed to only five products ({$in: ['prod1', 'prod2', 'prod3', 'prod4', 'prod5']}
), the product count is somehow 8?! And this is the only place in my entire app where a subscription to products
is being set up.
I’m stumped. What am I missing?