Closed tobiu closed 1 month ago
I think the new syntax would be better unless the prior syntax enables flexibility in combining field values to produce a calculated value. Obviously, this calculation could be done in another way prior to the binding so this flexibility might not be necessary. One question about the new syntax seems unclear: How does it bind to a stock config like the "value" property of the TextField?
the properties (keys) inside the bind object are the names of the configs. for one way bindings, we do need the transformation function. using fat arrows is optional.
so, with the new syntax, I could do this?
bind: {
value: {twoWay: true, property: 'data.foo.bar.baz'}
},
I would like to close this ticket, since the first version is working fine.
You can test it inside Neo.examples.model.twoWay
.
I did test the other approach a bit, but this one is complicated: we would need to use new Function('data', `data.${value.property}`)
inside createBindings()
, but also adjust parseConfigs()
.
Some security issues and time consuming.
You are welcome to create a follow-up ticket though, in case you think it is important.
Right now, 2way only works in case the name of the config is exactly the same as the name of the bound data prop:
This was obviously not intentional.
We should evaluate if we want to keep the current syntax or modify it. 2way kind of enforces to only allow direct bindings and no field combinations, since we can not know how to transform back out of the box.
So we would either use the regex-parsing inside VMs or adjust the syntax. e.g.: