[英]Meteor: Synchronous method
I'm failing to run a method on the server side synchronously, meaning to wait for it to be done. 我无法在服务器端同步运行方法,这意味着要等待它完成。
mymethod: function(par1, par2){
var timer = Meteor.setTimeout(function() {
//do something
});
}
I tried to use Meteor.wrapAsync without success, whether I wrap the timer or the entire method like this: 我尝试使用Meteor.wrapAsync失败,无论是包装计时器还是像这样的整个方法:
Meteor.wrapAsync(Meteor.call('mymethod', par1, par2));
Weird. 奇怪的。
if (Meteor.isServer) {
Meteor.methods({
mymethod: function(par1, par2) {
var timer = Meteor.setTimeout(function() {
console.log("Hey!");
}, 1000);
}
});
Meteor.call('mymethod', 'par1', 'par2');
}
works fine here in a newly created 0.9.3.1 app. 在新创建的0.9.3.1应用中可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.