views:

49

answers:

1

I am implementing a barebones framework in JavaScript that just provides data-binding between objects. The data-binding can either be one-way or two-way, and potentially have multiple objects bound on some property. There are several data-binding solutions available for various languages and I am trying to get a good idea of the best of all worlds to cherry pick the feature set from. So far I have researched the following frameworks that provide bindings:

Please feel free to edit the question and add additional frameworks that support binding if they are missing.

What data-binding features do you find extremely valuable in your respective framework of choice? The objective of this framework will be to eliminate as much of the glue code as humanly possible. Also, are there any research papers on the topic that I can munch on?

+1  A: 

Also look at one of the oldest of them all: the Tk toolkit (usually associated with tcl but is also available in other languages). In Tk updating a value in the GUI is typically done by simply updating a variable:

set foo "Hello" ;# just a simple variable

# Create a label widget displaying "Hello"
pack [label .l -textvariable foo]

# Now change "Hello" to "Goodbye"
set foo "Goodbye"

Or a more involved example, a 10 second countdown widget:

set countdown 10
pack [label .count -textvariable countdown]

proc tick {} {
    incr countdown -1
    if {$countdown > 0} {
        after 1000 tick
    }
}
tick

Actually, the feature is derived from the tcl language itself via the trace command:

# A simple auto-incrementing variable:

set foo 0
proc autoIncrement {varname args} {
    incr $varname
}
trace add variable foo read {autoIncrement foo}

# now every time foo is read it increments itself by 1

Of course, you can't expect all languages to have this feature. You can sort of emulate it by polling though, using setInterval() perhaps. The way Tk does it feels most natural to me.

slebetman