News for hackers. Stuff that matters.
Re:A curated list of things related to Vue.js by jbreckmckye on Saturday September 02, 2017 @09:48AM (#15155944)
Why not just add your property with "vue.set()"?

I feel you could have avoided this "awful" pain by just reading a little documentation.

I mean, how exactly did you think your new property would be picked up? I know frameworks are supposed to abstract over things but you do still need some idea what's happening under the hood.

Re:A curated list of things related to Vue.js by fishtank on Saturday September 02, 2017 @09:57AM (#15155984)
Vue.set is the way to go here, which used to be more prominent in the docs. The section that called this out (along with other reactivity "gotchas") has apparently been removed from the latest version.

Here's an archive link: http://web.archive.org/web/20170711045330/https://vuejs.org/...

Re:A curated list of things related to Vue.js by alevans4 on Saturday September 02, 2017 @12:50PM (#15156959)
They moved it. It's under List Rendering now in the guide. I have no idea why. https://vuejs.org/v2/guide/list.html#Object-Change-Detection...
Re:A curated list of things related to Vue.js by roblabla on Saturday September 02, 2017 @10:44AM (#15156193)
The problem is, Vue.set is documented exactly nowhere in the getting started guide[0]. In my case, I couldn't use it because I wasn't the one modifying the data binder, d3-force was. But either way, this should definitely be in the guide !

Besides, it's possible for the new property to be picked up through Proxy Objects[1]. So it's not like it's entirely impossible for Vue to do this, they just chose not to (and they probably have good reason, like IE support).

[0]: https://vuejs.org/v2/guide/index.html

[1]: https://caniuse.com/#feat=proxy

Re:A curated list of things related to Vue.js by alevans4 on Saturday September 02, 2017 @12:54PM (#15156981)
I spend a good amount a time answering questions in the Vue StackOverflow tags. While this is documented, it's nevertheless something a huge amount of people stumble over. I'd say the change detection caveats are right behind "this" issues (which isn't really a Vue issue, just javascript) in terms of the most common problems I see in Vue code.
Re:A curated list of things related to Vue.js by masklinn on Saturday September 02, 2017 @09:55AM (#15155969)
> I mean, how exactly did you think your new property would be picked up?

If mutations of existing properties are picked up, one could naturally expect that addition of new properties would also be.

Re:A curated list of things related to Vue.js by gcr on Saturday September 02, 2017 @10:29AM (#15156128)
Thanks for the hint. This will help me in my own project.

One question: Which objects will Vue attach observers to? Just props and data? I sometimes reference objects in Computed values, but those objects never seem to force re-rendering when they're changed.