【发布时间】:2014-09-06 13:22:13
【问题描述】:
我正试图弄清楚如何防止模板在 Meteor.users.update() 完成之前更新。
首先,我试图弄清documentation and the use of an optional callback argument 的含义,以便弄清楚发生了什么。
这是我所拥有的:
Meteor.users.update(Meteor.userId(),
{$set:{'profile.reviewList': []}},
[],
function(err, result){
if (err){
console.log('oh no!');
} else {
console.log('Result achieved: '+this.profile.reviewList);
}
});
目前console.log('Result achieved: '+this.profile.reviewList); 总是第一次返回类似...TypeError: Cannot read property 'reviewList' of undefined... 的东西,但它告诉我它在结果返回之前被触发。
我确定我没有正确实现回调,但我试图模拟这个答案:How do you ensure an update has finished in meteor before running a find?
我真的很想延迟关联模板的重新渲染,直到属性被创建。
任何帮助将不胜感激。
【问题讨论】:
标签: meteor