maoberlehner/vuex-map-fields

Large object field mapping

mrdigitalau opened this issue · 1 comments

Hey mate,

Thanks for this spectacular plugin.

I have a question I can't seem to wrap my head around.

I have a large object, it's an application form.

I have an object like this (BUT much larger) in my store::

application: {
  fname:null,
  lname:null,
  email:null,
 phone:null
}

I have mapped it to my store
...mapFields(['application']),

If I create a text input and use v-model="application.fname", when looking inside of my Vue Chrome Plugin, the store isn't being updated, so I can't see the changes there, but if I echo the application object into my component {{application}} and see the raw data, it is being updated.

Is this correct way in doing this? Because it's such a large object, I really don't want to have to manually map every single field.

The way I've done it, even though it's not tracking the changes in the store, is it still acceptable to do it this way?

@mrdigitalau mapFields doesn't support that unfortunately. The way you are working with it breaks reactivity. The point of using a store is to share your data between components. If it's not in the store then you won't be able to do that. So it's up to you whether you need the store or not.

You might want to try dynamicMapFields as per #24 (comment). That way (provided you already have the list of fields as data in some format) you should be able to convert that to an array that can be mapped rather than manually mapping each field.