Live data from Hacker News

Show HN: Way.js – Simple, persistent, framework-agnostic two-way databinding

gwendall.github.io

11–20 of 62 posts

Re: Show HN: Way.js – Simple, persistent, framework-agnostic two-way databinding

#12
post #11

That's the only javascript framework one needs. Actually I've been wanting to write something like that for a long time but didn't get around to it. Nice to see someone else did exactly what I wanted...

Does anybody have real world examples of websites that use this kind of thing?

Im always under the assumption that the old "post data to server, save it there" model still works best. Am I missing something?

Re: Show HN: Way.js – Simple, persistent, framework-agnostic two-way databinding

#13
post #5

Looks very straight-forward. Good job! OT: After building a couple of large applications in Angular I've come to realize that I seldom need two-way bindings. The school example where you enter something in an input box and it shows up somewhere else in real-time is not really used in the real world. Or is it? Why do we need two-way data binding?

I rarely need _simultaneous_ two-way databinding. But I do sometimes need databinding from view to model (when I want users to enter data, and it just fills in my object), and I sometimes want databinding from model to view (where my data is nicely displayed). So rather than doing something fiddly and different for each way, it makes more sense to just have 2-way databinding in the first place. And that then makes it…

> allowing users to enter a filter

Wouldn't it be enough to add a keydown event to the field?

Re: Show HN: Way.js – Simple, persistent, framework-agnostic two-way databinding

#14
post #5

Looks very straight-forward. Good job! OT: After building a couple of large applications in Angular I've come to realize that I seldom need two-way bindings. The school example where you enter something in an input box and it shows up somewhere else in real-time is not really used in the real world. Or is it? Why do we need two-way data binding?

How about: Enter an amount in an input box and see a sub-total in real-time, or alert when constraints are violated? Possibilities are endless and you're more likely to implement them when it is so painless.

Is it really more painless to add way.js and its dependencies (jquery.js, underscore.js, underscore.json.js, form2js.js and js2form.js) to your page then to simply add a plain javascript eventhandler to the field you want to validate?

Re: Show HN: Way.js – Simple, persistent, framework-agnostic two-way databinding

#16
post #14

Earlier quoted context omitted.

How about: Enter an amount in an input box and see a sub-total in real-time, or alert when constraints are violated? Possibilities are endless and you're more likely to implement them when it is so painless.

Is it really more painless to add way.js and its dependencies (jquery.js, underscore.js, underscore.json.js, form2js.js and js2form.js) to your page then to simply add a plain javascript eventhandler to the field you want to validate?

That depends. How many forms and how many fields do you need to validate? jQuery is pretty much standard on most websites, so I don't count that against the author. The total minified dependency file is 123 kb. I will agree that is pretty large if all you are using it for is a single field, but again, a large portion of that is jquery. Also compared to just core angular, which is 104 kb, I would say this is a viable alternative depending of course on your specific use cases.

That being said, could an implementation be done without jQuery? Probably. I'm sure the author is open to pull requests if you want to give it a go.

Re: Show HN: Way.js – Simple, persistent, framework-agnostic two-way databinding

#18
post #12
post #11

That's the only javascript framework one needs. Actually I've been wanting to write something like that for a long time but didn't get around to it. Nice to see someone else did exactly what I wanted...

Does anybody have real world examples of websites that use this kind of thing? Im always under the assumption that the old "post data to server, save it there" model still works best. Am I missing something?

Two way binding doesn't necessarily negate that.

Re: Show HN: Way.js – Simple, persistent, framework-agnostic two-way databinding

#19
post #11

That's the only javascript framework one needs. Actually I've been wanting to write something like that for a long time but didn't get around to it. Nice to see someone else did exactly what I wanted...

Has Knockout not worked for you?

Re: Show HN: Way.js – Simple, persistent, framework-agnostic two-way databinding

#20
post #12
post #11

That's the only javascript framework one needs. Actually I've been wanting to write something like that for a long time but didn't get around to it. Nice to see someone else did exactly what I wanted...

Does anybody have real world examples of websites that use this kind of thing? Im always under the assumption that the old "post data to server, save it there" model still works best. Am I missing something?

One possible use case is "live editing" of an object. Imagine a form that lets you build an HTML button from various properties: text, color, font, background, border-radius etc.

Using way.js the button can be updated immediately whenever you change one of its properties, without waiting for a server response.

And saving the data to localstorage is very useful when the user is spending a long time filling the form and then accidentally closes the browser / clicks BACK / etc. It's a bit like autosaving a draft version of the form.

Post reply on HN