2015-10-06 35 views
1

我有兩個按鈕用作點擊時在後端觸發方法的「開始」和「停止」。 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,直到其他方法解鎖。有沒有解決的辦法?

回答

0

this.unblock允許在前一個方法調用完成之前執行後續方法調用。聽起來就像你想在功能開始時將它移動到第一行一樣

+1

因爲我不想讓_other_ meteor方法被調用,所以只有'stop' – corvid

相關問題