A one way binding looks like this:
bind: {
startTime: value: data => data.startTime
}
It should be optionally possible to not only update component configs when view model data props change, but also support the other direction. Change a component configs => update the bound model data property.
bind: {
startTime: {twoWay: true, value: data => data.startTime}
}
To do this, model.Component needs to check if a config object was passed. If so, use value.value.
Neo.mjs: set() needs an update, to also call this.afterSetConfig() in case the fn does exist.
This method needs to get implemented on component.Base (lowest VM entry point).
afterSetConfig(key, value, oldValue) {
if (Neo.currentWorker.isUsingViewModels) {
let me = this,
bind = me.bind;
if (bind && bind[key] && bind[key].twoWay) {
me.getModel().setData(key, value);
}
}
}
A one way binding looks like this:
bind: { startTime: value: data => data.startTime }It should be optionally possible to not only update component configs when view model data props change, but also support the other direction. Change a component configs => update the bound model data property.
bind: { startTime: {twoWay: true, value: data => data.startTime} }To do this, model.Component needs to check if a config object was passed. If so, use
value.value.Neo.mjs: set() needs an update, to also call
this.afterSetConfig()in case the fn does exist.This method needs to get implemented on
component.Base(lowest VM entry point).afterSetConfig(key, value, oldValue) { if (Neo.currentWorker.isUsingViewModels) { let me = this, bind = me.bind; if (bind && bind[key] && bind[key].twoWay) { me.getModel().setData(key, value); } } }