I am working on meteor app. I want to reload the content of the client when the database variable has changed. I am using pub-sub. I want to load content if the status variable has changed.
Meteor.publish('activities', function(loggedInUserToken) { var authObj = AuthenticationToken.findOne({ authToken: loggedInUserToken }); if (authObj) { var userObj = Users.findOne({ _id: authObj.user_id }); var activities = Activities.find({}, { sort: { createdAt: -1 } }); return activities; } return this.ready(); });Template.masterSku.onCreated(function() {
var instance = this;
instance.autorun(function() {
var loggedInUserToken = “xxxxxxxxxxxxxxxx”
statusSuscription = instance.subscribe(“activities”, loggedInUserToken);
var activitiesObj = Activities.findOne({}, { sort: { createdAt: -1 } })
if (activitiesObj && activitiesObj.status == “true”) {
console.log(“Status Changed load Content accordingly”)
}
})
#node.js #meteor