Sencha touch 如何在Sencha Touch中的门店间同步

Sencha touch 如何在Sencha Touch中的门店间同步,sencha-touch,extjs,Sencha Touch,Extjs,我有一个Sencha Touch应用程序,它使用REST代理将数据从REST服务加载到商店。此存储的load事件还将记录复制到localstorage存储中。这是因为应用程序需要在脱机模式下工作。我正在尝试将对localstorage中的记录所做的更改写回REST服务,但还没有找到如何同步localstorage存储和使用REST代理的存储的方法。有什么想法吗 我遵循了这里给出的示例,但它只涉及脱机数据的只读场景。您需要在localstorage存储上的save事件中实现类似的功能,将更改复制到

我有一个Sencha Touch应用程序,它使用REST代理将数据从REST服务加载到商店。此存储的load事件还将记录复制到localstorage存储中。这是因为应用程序需要在脱机模式下工作。我正在尝试将对localstorage中的记录所做的更改写回REST服务,但还没有找到如何同步localstorage存储和使用REST代理的存储的方法。有什么想法吗


我遵循了这里给出的示例,但它只涉及脱机数据的只读场景。

您需要在
localstorage
存储上的save事件中实现类似的功能,将更改复制到
onlineStore
(就像你在加载时将新商品从
在线商店
复制到
离线商店

@Lyle Pratt拥有从“离线”商店复制到“在线”商店的功能是正确的但是为了扩展它,我将在你的离线商店中创建一个函数,它将把你的离线数据保存或复制到你的在线商店中

Ext.define('MyProject.store.OfflineMessage', {
    config: {
        model: 'MyProject.model.Message' //this should be the same with your online store

    },

    sync: function(){
        var me = this, 
            onlineMessageStore = Ext.getStore('OnlineMessage'), //you can get your current store or just create a new one
            items = me.getData().items; 

        onlineMessageStore.setData(items);
        onlineMessageStore.sync();

    }
});

另一方面,您也可以为在线商店创建相同的功能,将在线数据保存到离线商店。

您找到方法了吗。?
Ext.define('MyProject.store.OfflineMessage', {
    config: {
        model: 'MyProject.model.Message' //this should be the same with your online store

    },

    sync: function(){
        var me = this, 
            onlineMessageStore = Ext.getStore('OnlineMessage'), //you can get your current store or just create a new one
            items = me.getData().items; 

        onlineMessageStore.setData(items);
        onlineMessageStore.sync();

    }
});