4 ms·
It's pretty nice, but you don't get two-way binding for free and it's not really baked in. In your example you'd have to use an input or content-editable elemen
by WorldWideWayne 11y ago
It's pretty nice, but you don't get two-way binding for free and it's not really baked in. In your example you'd have to use an input or content-editable element and then call ractive.observe and write your own code for binding user-input to your model data.
Compare to something like Knockout.js where you don't write any special code to get the two-way binding (other than creating each data field as an 'observable' field.)
- ThrustVectoring 11y agoMuch like Javascript's "==" operator gives you type conversion for "free", it's not clear to me that getting two-way binding for "free" is a good thing. One-way binding is significantly easier to reason about.
- dkempner 11y agoMost of the time, data binding IS one-way when using Knockout. Input field? That's one-way from display => a variable in your viewmodel. P tag? That's one-way from variable in viewmodel => display. But when do you really need two-way data binding? Form validation and formatting. Man, this stuff is hard even with two-way data binding. You have to be able to accept, parse, format, and validate all in the same element. It's very helpful to be able to use knockout for a task like this.
- nailer 11y agoIn my example, I'd just add <input value={{ some }}> That's all.
- nailer 11y agoPS. if it's not clear, that's a response to: > In your example you'd have to use an input or content-editable element and then call ractive.observe and write your own code for binding user-input to your model data. Using an input element is enough. Try it.
- WorldWideWayne 11y agoThanks for the correction. I thought about moving to a system that uses React or something like it and I looked at a bunch of them, but I'm sticking with Knockout for now because it lets me keep my markup in the HTML document where I personally think it belongs. I'll probably end up moving to Aurelia (or something like it) because it's so pluggable and you can use it with React or not. There are so many choices right now, it's hard to decide!! Sticking with whatever I pick is also sometimes difficult, but I've been using Knockout for about a year now.