gothinkster / vue-realworld-example-app

An exemplary real-world application built with Vue.js, Vuex, axios and different other technologies. This is a good example to discover Vue for beginners.
https://vue-vuex-realworld.netlify.com
MIT License
4.06k stars 1.3k forks source link

Vuex store modifcations #17

Open psychonetic opened 6 years ago

psychonetic commented 6 years ago

Hello,

if I am not mistaken, the store is not used in strict mode and if you would change it to strict, you would have a lot of errors like "don't vuex mutate state outside store". Because you are binding all properties of an object directly to v-model. In my opinion this is not good practice, because mutating outside of store can lead to unexpected behaviour in big applications and so debugging would be hell. I think this should be fixed. Either cloning the object before mutating or set for each properties the setter and getter methods, see: https://vuex.vuejs.org/en/forms.html

If you already know this, you should at least mention that inside documentation.

Cheers,

Marco

vilsbole commented 6 years ago

@psychonetic Yes it's an important change to make! We should turn on strict mode and remove all store mutations inside a component.