News for hackers. Stuff that matters.
Re:Vue.js: the good, the meh, and the ugly by kevin_thibedeau on Thursday July 05, 2018 @06:10PM (#17467285)
> I am never a fan of two way data binding as an alternative.

The author is wrong. Vue doesn't have two-way binding. It has one-way binding with events. Components can't force anything upon their parent's state with an event.

Re:Vue.js: the good, the meh, and the ugly by aylmao on Thursday July 05, 2018 @06:47PM (#17467507)
I mean, Vue calls it two-way data binding. From their website:

> "You can use the v-model directive to create two-way data bindings on form input and textarea elements. It automatically picks the correct way to update the element based on the input type. Although a bit magical, v-model is essentially syntax sugar for updating data on user input events, plus special care for some edge cases."

I'm not knowledgeable enough on the matter to say if this is or isn't, and to compare vs Angular, etc. But don't blame the author for this one ¯\_(ツ)_/¯

[1] https://vuejs.org/v2/guide/forms.html

Re:Vue.js: the good, the meh, and the ugly by kevin_thibedeau on Thursday July 05, 2018 @10:59PM (#17468546)
"v-model" is syntax sugar emulating a two-way binding to simplify form creation. Under the hood it's a one-way bound prop, an event, and an implicit event handler. Ordinary events can't mutate state without an explicitly created handler.

  All props form a one-way-down binding between
  the child property and the parent one: when the
  parent property updates, it will flow down to
  the child, but not the other way around. This
  prevents child components from accidentally
  mutating the parent’s state, which can make
  your app’s data flow harder to understand.
https://vuejs.org/v2/guide/components-props.html#One-Way-Dat...

  AngularJS uses two-way binding between scopes,
  while Vue enforces a one-way data flow between
  components. This makes the flow of data easier
  to reason about in non-trivial applications.
https://vuejs.org/v2/guide/comparison.html#Data-binding
Re:Vue.js: the good, the meh, and the ugly by orangecat on Thursday July 05, 2018 @08:12PM (#17467956)
As discussed in https://vuejs.org/v2/guide/components.html#Using-v-model-on-...

  <Component v-model="foo">
is basically shorthand for

  <Component :value="foo" @input="foo=$event">
In particular, the child can't affect the value of the parent's "foo" attribute except by sending an event. This is in contrast to Angular 1 where changing "foo" in the child would also change it in the parent, which would often lead to confusing data flow cycles.
Re:Vue.js: the good, the meh, and the ugly by ipntu on Friday July 06, 2018 @04:35AM (#17469873)
A shame that this answer was downvoted on a technicality.

As other people mentioned, Vue indeed doesn't have two-way binding, and v-model doesn't have the pitfalls that Angular had. It is just syntax sugar.

Maybe it's about time Vue people remove the mention of two-way binding from their websites, since it is being used to attack the framework. I've seen that in other discussions here in Hacker News.

Re:Vue.js: the good, the meh, and the ugly by Too on Saturday July 07, 2018 @03:35AM (#17477534)
Vue also has "1.5-way binding" with computed properties, which is what you normally need 2-way binding for, but without all the problems full 2-way binding might introduce.