Why is there no sync callback in Sencha Touch?

谁说我不能喝 提交于 2019-12-05 09:29:48
Zoltan Magyar

It took us ages to find a proper solution to this. Finally we added listener to the store's write event what seems to be working properly. As it is needed frequently it has been added to the store prototype as

Ext.data.Store.prototype.syncWithListener = function(onWriteComplete, syncMethod) {

    this.on('write', onWriteComplete, this, {single:true});

    var syncResult = syncMethod ? syncMethod.apply(this) : this.sync();

    if (syncResult.added.length === 0 &&
        syncResult.updated.length === 0 &&
        syncResult.removed.length === 0) {

        this.removeListener('write', onWriteComplete, this, {single:true});
        onWriteComplete(this);    
    }

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