alteryx / alteryx/Optimization
Syncing dataItems with the Mobx store
- 主要语言
- JavaScript
- 星标
- 0
- 派生
- 0
- PR 合并指标
- 30 天内没有已合并 PR
描述
``` js
import { extendObservable, observable, computed, autorun } from 'mobx'; //eslint-disable-line
const dataItems = [
{obsName: 'editorValue', dataName: 'FormulaFields', mode: 'read'},
{obsName: 'varList', dataName: 'fieldNames', mode: 'read'},
{obsName: 'constraints', dataName: 'constraints', mode: 'write'},
{obsName: 'objective', dataName: 'objective', mode: 'write'},
{obsName: 'fieldList', dataName: 'fieldList', mode: 'write'}
]
class AyxStore {
constructor(manager, dataItems){
dataItems.forEach(d => {
const item = manager.GetDataItemByDataName(d.dataName)
if (d.mode === 'read'){
this[d.obsName] = item.getValue()
item.BindUserDataChanged(v => { this[d.obsName] = v; })
} else {
this[d.obsName] = JSON.parse(item.getValue())
autorun(() => item.setValue(JSON.stringify(this[d.obsName].toJSON())))
}
})
}
}
```
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。