铁路由器无限循环onBeforeAction
问题描述:
自Meteor 1.0以来,我在钩子onBeforeAction上有一个无限循环。 (create_game永远叫)铁路由器无限循环onBeforeAction
onBeforeAction: function(){
if(Meteor.userId()){
Meteor.call('create_game', this.params._id, 1, function(error, result){
if (error)
console.log(error);
else{
game_sus = result;
Session.set('gamesolo_id', game_sus);
}
});
}
this.next();
},
waitOn: function() { return Meteor.subscribe('game', Session.get('gamesolo_id))}
的无限循环是由于会话变量的原因,如果我删除它,我没有在一个循环进入。我不知道这是否是由于新版本或者什么原因导致的错误,但是您是否有任何想法可以解决这个问题? 我试着用一个全局变量而不是一个会话变量,但我没有以这种方式订阅。
答
onBeforeAction是被动,所以如果你设置Meteor.call回调会话变量,然后onBeforeAction将再次运行
您可以使用onRun本次会议设置