在Sencha Touch应用程序中自动刷新列表

Jig*_*dya 1 multithreading refresh sencha-touch

我正在开发一个简单的聊天应用程序,我可以在单击REFRESH按钮时查看更新的数据,但是我可以定期从服务器刷新数据(因为我的聊天远程存储在数据库中)

提前致谢.

Swa*_*war 8

使用Sencha Touch的DelayedTask类:

//create the delayed task instance with our callback
var task = Ext.create('Ext.util.DelayedTask', function() {
    //load the list's store here. The list will be automatically updated
    listComp.getStore().load();    // Assuming your list component is "listComp"
    listComp.refresh();    

    // The task will be called after each 10000 ms
    task.delay(10000);
}, this);

//The function will start after 0 milliseconds
//so we want to start instantly at first
task.delay(0);

//to stop the task, just call the cancel method
//task.cancel(); 
Run Code Online (Sandbox Code Playgroud)

这适用于您的情况.