我使用Sencha Ext.js我通过调用下面的startTask()在我的ViewController中启动任务。
Ext.define('Thingor.view.main.ThingGridController', {
extend: 'Ext.app.ViewController',
...
checkThingStatusResponse: function(result) {
console.log('result was');
console.log(result);
var fail = true;
var actionMessages = new Array;
var failMessages = new Array;
var gotFail = false;
var gotSuccess = false;
if (result != undefined) {
for (var x = 0; x < result.length; x++) {
if (result[x] != undefined) {
var thisResult = result[x];
var rc = thisResult.status;
if (rc != undefined) {
if (rc != 204 && rc != 200 ) {
fail = false; gotFail = true; console.log('perm error');
} else {
for (var thingStat = 0; thingStat < thisResult.results.length; thingStat++) {
var tresult = thisResult.results[thingStat];
fail = false;
gotSuccess = true;
console.log('thing ' + tresult._oid + ' has ' + tresult.status);
if( tresult.status == 'Ready' ) {
this.view.store.load();
// stop task here but how?
}
}
}
}
}
}
}
...
}, // end checkThingStatusResponse
checkThingStatus: function (thgOid) {
this.myAsyncExec(
Thingor.Utils.globals.apiEndpoint + '/Thing/' + thgOid
, ''
, 'GET'
, ''
, 'checkThingStatusResponse'
, this.id
);
}
, startTask: function (thgOid) {
console.log('Starting task for new Thing[' + thgOid + "]");
Ext.TaskManager.start({ run: this.checkThingStatus(thgOid), interval: 10000});
}
, stopTask: function (thgOid) {}
我的任务似乎运行正常,期待我收到此错误消息:
[E] Error while running task - TypeError: Cannot read property 'apply' of undefined ext-all-rtl-debug.js?_dc=1437767086048:5683
我以某种方式导致此错误? 我还将如何阻止我的任务呢?