【发布时间】:2016-07-28 20:42:25
【问题描述】:
这个 Meteor 客户端公共方法需要在 Meteor.user().profile.propA 更改时重新运行,这很好,但是当 profile.propB 更改或添加时它也会运行。当profile 的任何其他 子属性已更改或添加但仅适用于profile.propA 时,如何阻止它重新运行?谢谢
myListener: () => {
Tracker.autorun(() => {
if (Meteor.userId()) {
const indexes = Meteor.user().profile.propA;
if (!indexes || indexes.length <= 0) return;
dict.set('myStuff', indexes);
console.log('auto has run');
}
});
},
在 mongodb 终端上:
db.users.update({'_id':'123abc'}, {$set: {'profile.propB':'B'}})
触发自动运行。即使响应式数据源是Meteor.user().profile.propA;
【问题讨论】:
标签: meteor