Is there any way to create a callback or something similar?
afuno opened this issue · 4 comments
After changing the data in the text field, a mutation named updateField
is performed. I needed to call a different mutation every time updateField
is executed. Can you please tell me how can I implement this? Maybe you have the ability to rewrite the mutation with the addition of custom code to implement the callback? Or do you already have the ability to specify a callback? I didn't find anything about it in the documentation.
It is documented here: https://github.com/maoberlehner/vuex-map-fields#component-2
Use CreateHelpers
.
@geoidesic But I only see hashes with types. Maybe I misunderstand something?
@afuno maybe I don't understand what you're trying to do. Perhaps show some code?
I don't know what you mean by hashes with types
or what that has to do with what I posted. Hashes are not a JavaScript concept as far as I'm aware.
My understanding is that you are asking if it's possible to map to a different mutation other than updateField
. You can do this as documented in the link I've shown. Effectively you create your own mapper which registers your own mutation or getter for the getter and setter that gets created.
So to restate what is stated in the link provided, let's say you want to use your own mutation called "updateDateField", then you create your own mapping function using the helper:
const mapHelpers = CreateHelpers({options: {mutationType: 'updateDateField'}});
const myMapFields = mapHelpers.mapFields;
...
computed:{
...myMapFields('myStoreModule',['myVuexPath'])
Then instead of calling the updateField
mutation, the setter will call updateDateField
mutation.