Data binding

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Data binding

Harmath Dénes
Playing around with Scala, I've come up with a little data binding  
"framework". Here it is:

BindingTest demonstrates the usage. A property can be bound to another  
via an updater function, or a property can be simply observed, calling  
a function when the value changes (typically with a side-effect).

- () has to be written after every reference to a property (but still  
better than JavaBeans' get*()/set*())
- bindings are functions, so the syntactic overhead () => ... is  
required for all of them
There is an implementation "hack":
- Observe passes the bound function to the property's apply() as a  
global variable
- ability to define constraints for properties
- implicitly inject properties to fields of POSOs (not sure if possible)

Feedback etc. are welcome.