Basic data binding examples

I am implementing a barebones schema in JavaScript that simply provides data binding between objects. Data binding can be one-way or two-way and potentially have several objects bound to some property. There are several data binding solutions available for different languages, and I'm trying to get an idea of ​​the best of all worlds so that cherry chooses a set of functions. So far, I have explored the following structures that provide bindings:

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

What data binding features do you find extremely valuable in their respective frameworks? The purpose of this structure will be to eliminate as much of the glue code as possible. Also, are there any research articles on this subject that I can go for?

+3
source share
1 answer

Also look at one of the oldest of them: Tk toolkit (usually associated with tcl, but also available in other languages). When updating Tk, the value in the GUI is usually done by simply updating the 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 attractive 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, this function is displayed in tcl through 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

, , . , , , setInterval(). , Tk .

+1

Source: https://habr.com/ru/post/1763924/


All Articles