alteryx / alteryx/Optimization
Syncing dataItems with the Mobx store
- Ngôn ngữ chính
- JavaScript
- Star
- 0
- Fork
- 0
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
``` 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())))
}
})
}
}
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.