在另一个正在执行时调用meteor方法

时间:2015-10-06 13:38:14

标签: javascript meteor

我有两个按钮,用作"开始"并且"停止"单击后触发后端方法。 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,直到其他方法解锁。有办法解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

this.unblock允许后续方法调用在前一个方法调用完成之前执行。听起来好像你想在函数开始时将它移到第一行