Re:In search of the perfect JavaScript framework
by AdamCraven on Sunday February 08, 2015 @07:03AM
(#9017043)
What you are linking to is still two-way data binding. Which enforces a one-way flow of data.
Two-way binding: Read & Write. Read & Write happens through getter/setter methods.
One-way binding: Read only. Writes happen by external event listeners.
Both can be used to enforce one way flow of data. Just as one way binding can be used to have a uni-directional flow of data.
A pseudo code example with two-way data binding with one-way flow of data:
<input type="text" value=getOrSetValue() />
function getOrSetValue(newValue) {
if (newValue) {
// Send an event to a dispatcher with updated value.
} else {
return value // can be single value from model or derived value, such as calculation of multiple values.
}
}
Re:In search of the perfect JavaScript framework
by jdmichal on Sunday February 08, 2015 @03:27AM
(#9016753)
I believe the intention is basically "bind to a setter method, not a field." I'm guessing for much the same reasons the same is used in Java: You can change methods. You can add sanity checks, new behavior, etc.
[1]: http://facebook.github.io/react/docs/two-way-binding-helpers...