Reputation: 25552
Here is my subscribe:
Meteor.subscribe('jobs', Session.get('currentIndustryOnet'));
publish:
Meteor.publish('jobs', function(onet_code){
console.log(onet_code);
if(onet_code)
return Jobs.find({onet: onet_code});
else
return Jobs.find({});
})
Obviously this isn't working, but I am just not sure how to fix this. Basically, when a user selects from a drop down list of options, the subscription should update with the onet_code passed in via the Session variable.
Upvotes: 1
Views: 74
Reputation: 36940
You're missing one line:
Deps.autorun(function (){
Meteor.subscribe('jobs', Session.get('currentIndustryOnet'));
});
Welcome to the magic of Meteor.
To understand how this works, note that
Deps.autorun
calls the function again when any reactive dependencies are invalidated from the last time it was called; andDeps.autorun
automatically cleans up any previous subscriptions that were started in a previous call after starting the new one.See also http://docs.meteor.com/#deps_autorun
Upvotes: 2