商店变化绑定公式

Bind formula for changes in store

我有公式,想在 viewModel 中存储 changeData 时执行它。

当我这样做时,当存储中的数据发生变化时公式不起作用

stores: {

    currentStore: {
        extend: 'Ext.store.MyStore',
        trackRemoved: false
    },
    },
    formulas: {

    'executeWhenStoreChange': {
        bind: '{currentStore}',

        get: function () {
           console.log('store change')
    },

如果您希望在数据更改时触发函数,我会使用 datachanged 监听器来监听您希望事件触发的商店。

    currentStore: {
        listeners: {
            datachanged: function(store, eOpts) {
                console.log('store change');
            }
        }
    },

如果您希望所有商店都使用它,只需在每个 datachanged 侦听器

中引用该函数
    currentStoreA: {
        listeners: {
            datachanged: 'onStoreDataChangeD'
        }
    },
    currentStoreB: {
        listeners: {
            datachanged: 'onStoreDataChangeD'
        }
    },

然后在视图控制器中:

    onStoreDataChangeD: function(store, eOpts) {
    console.log('store changed');
}