vuejs / vuex

🗃️ Centralized State Management for Vue.js.
https://vuex.vuejs.org
MIT License
28.42k stars 9.58k forks source link

Easy two-way binding between v-model and vuex? #2141

Open maerf opened 2 years ago

maerf commented 2 years ago

What problem does this feature solve?

Is there any solution for quick low-/no-overhead databinding to something like a store object? Implemented? Library suicide pact?

All this boilerplate code just to set up two-way data binding is abomination.Maybe it's too late already, looking at popularity graphs. Anyone that watches a tutorial on databinding with vuex will surely have puked and ran away. It's a shame.

If there is no better concept, just create all these mindless getter setter and mutator methods IMPLICITLY unless definedI. I perhaps fail to understand how that is not better in any case (if properly communicated that this happens).

I think C# does something similar:

C# property sample: public int Age { get; set; }

Is the same as: private int age; public int Age { public get { return this.age; } public set { this.age = value; } }

Btw, if you want read only, in C# you can make the setter private for example: public string Age { get; private set; }

Works since 2012 or so. But what do they know about creating a popular language.

What does the proposed API look like?

Simply generate the default boilerplate getter setters and mutations (on build), if the user doesn't define any.