我有一个商店,我想在每次完成某些操作时手动同步它。
我想知道的是是否有办法在商店配置上建立默认同步回调函数。
我知道我可以做这样的事情:
store.sync({
success: function(batch, options) {
console.log('ok');
},
failure: function(batch, options) {
console.log('not ok');
}
});
但是我想在商店本身中定义一次回调,然后我只需调用 store.sync();
这是我正在使用的商店的示例:
Ext.define('MyApp.store.MyStore', {
extend: 'Ext.data.Store',
alias: 'store.MyStore',
model: 'MyApp.model.MyModel',
autoLoad: true,
proxy: {
type: 'rest',
url: '../../api/myEndPoint',
noCache: false,
reader: {
type: 'json',
rootProperty: 'data',
successProperty: 'success',
totalProperty: 'total'
},
actionMethods: {
read: 'GET',
destroy: 'DELETE'
},
extraParams: {
type: 'aux'
}
},
});