为什么在查询内部查询更改时通知不会触发?当我把这个代码放在一个帮助器中时,它只能用于那个助手模板。
Tracker.autorun(function () {
Meteor.subscribe('theNotificationStatus');
Meteor.subscribe('theNotificationSubscriptions');
var currentUserID = Meteor.userId();
var usersEventIds = Subscriptions.find({userID: currentUserID}, {"eventID": 1});
var userCategorys = Subscriptions.find({userID: currentUserID}, {"category": 1});
var arrayEvents = [];
var arrayCategory =[];
usersEventIds.forEach(function (collection) {
arrayEvents.push(collection.eventID);
});
userCategorys.forEach(function (collection) {
arrayCategory.push(collection.category);
});
//All of the status's the user should be notified for based on what eventID and categories he/she is subscribed to.
var query = Status.find({ $and: [ { eventID: { $in: arrayEvents } } , { category: { $in: arrayCategory } }, { createdBy: { $ne: currentUserID } } ] }, {sort: {date: -1} } );
var handle = query.observe({
added: function (id, fields) {
sAlert.success('New Notifications', {timeout: '6000'});
},
});
// After five seconds, stop keeping the count.
setTimeout(function () {handle.stop();}, 5000);
});
答案 0 :(得分:0)
如果您使用React,将这些日志放入String user = getArguments().getString("user");
或Template.someTemplate.onCreated
时会得到什么日志?
componentWillMount