我有两个按钮,旨在充当“开始”和“停止”,单击时会在后端触发方法。例如:
{{#if isExecuting}}
{{>CylonButton method="stop"}}
{{else}}
{{>CylonButton method="start"}}
{{/if}}
meteor 方法如下所示。
Meteor.methods({
start: function (data) {
Cylon.downloadData(data); // chunks data and downloads it, could take a while
this.unblock(); // now that it's ready, it can be unblocked.
Cylon.load(); // do this longer running method.
},
stop: function () {
Cylon.stop(); // stop the method. This should _always_ be available
}
});
但是,在另一个方法解除阻止之前,我无法调用 stop
。有办法解决这个问题吗?
最佳答案
this.unblock
允许后续方法调用在前一个方法调用完成之前执行。听起来您想在函数开始时将其移至第一行
关于javascript - 当另一个方法正在执行时调用meteor方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32971478/