Auto Refresh the List in Sencha Touch Application

為{幸葍}努か 提交于 2019-12-04 18:45:20

Use DelayedTask class of Sencha Touch:

//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(); 

This should work for your case.

You just need to call your refresh() function at a regular right ?

So you just need to add a setTimeout("refresh()", 1000); at the end of your refresh() function. Then you just need to call it when your app startup.

Hope this helps

Maybe you'll be interested in socket server connection in your chat application. Server will notify your clients whenever server data changes. Take a look at http://socket.io/

please look at this. It will call the function for every (time you set). http://www.sencha.com/forum/showthread.php?194202-Autorefresh-List-with-DelayedTask

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!