在另一个正在执行时调用流星方法
问题描述:
我有两个按钮用作点击时在后端触发方法的“开始”和“停止”。 EG:在另一个正在执行时调用流星方法
{{#if isExecuting}}
{{>CylonButton method="stop"}}
{{else}}
{{>CylonButton method="start"}}
{{/if}}
流星方法看起来如下。
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
允许在前一个方法调用完成之前执行后续方法调用。听起来就像你想在功能开始时将它移动到第一行一样
因为我不想让_other_ meteor方法被调用,所以只有'stop' – corvid