[Vuejs]-Vuex – Create global method to dispatch action

0👍

I think that I found the right method to manage this scenario. I removed the store module’s “simplert” and I copied its functionalities inside a mixin. So I created inside mixin’s folder a simplert.js file, where I put all my logic to manage simplert alerts. Then in my components I imported the mixin when I need it. In this way I semplified the manage of simplert and I use it only in the components where need it

0👍

dispatch('ACTION', payload?, { root: true })

Setting the root option to true dispatches a root action. Which would be ‘ACTION’ in this case.

Without the root option this would dispatch a ‘MODULE_NAME/ACTION_WITHIN_MODULE’ action.

Leave a comment