FiguredLimited / vue-mc

Models and Collections for Vue
https://vuemc.io
MIT License
626 stars 98 forks source link

Docs: Storing model instances in components #113

Open majdal opened 5 years ago

majdal commented 5 years ago

I'm trying to find out how to fit vue-mc into my app's architecture, and the docs are helpful, but maybe I am missing something obvious:

In the Vue docs data section, it reads:

A rule of thumb is that data should just be data - it is not recommended to observe objects with their own stateful behavior.

Where should I store my model instance otherwise? That's the "vue-ful" way of doing so?

I'd be happy to add the results of this discussion to the vue-mc docs if the maintainers see that it's appropriate.

rtheunissen commented 4 years ago

I think the vue-ful way is to create components granularly and have your own HTTP modules, etc. A vue app done right probably doesn't need a package like vue-mc. In practice, we found that that is harder to achieve than we anticipated, so vue-mc helped to abstract a lot of duplicated patterns. The idea was that vue-mc is just a proxy to "just data", ie. it does what a component would do in its methods, except that the logic is moved to another module that can be isolated from Vue (for the most part), shared, and tested.

We didn't want vue-mc to maintain "state" and observers other than those automatically added by Vue. It just encapsulates the data for components. I don't believe that this fundamentally defies "the vue way", but also perhaps not a perfect fit.