Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VUEX - Many mapActions with same action name on the same page

I have several differents files for a lot of modules. Some of the share the same action name

There is some page that use 2 or more mapActions for different modules On my page is something like this:

methods: {
    ...mapActions({
        documents: ['setDocumentImage'],
        documentAddress: ['setDocumentImage'],
        selfie: ['setDocumentImage']
    }),
}

All my modules have a action setDocumentImage But the problem is that i have to invoke them like: this.setDocumentImage(file)

Is there a way to create an alias for each one of these mapAction that my page can differentiate? Or how can I fix it?

like image 258
Leonardo Cavalcante Avatar asked Nov 02 '25 03:11

Leonardo Cavalcante


1 Answers

Yes there is a way ! Here you are :

methods: {
    ...mapActions('documents', { setDocumentImage: 'setDocumentImage' }),
    ...mapActions('documentAddress', { setDocumentAddressImage: 'setDocumentImage' }),
    ...mapActions('selfie', { setSelfieDocumentImage: 'setDocumentImage' }),
}
like image 188
BTL Avatar answered Nov 04 '25 00:11

BTL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!