Is it bad to commit mutations without using actions in Vuex?

前端 未结 1 370
别跟我提以往
别跟我提以往 2021-01-05 00:23

I have been using Vuex for awhile now, and I have always been following the pattern: Components use Actions to commit Mutations to mutate the Store. I thought this was the p

相关标签:
1条回答
  • 2021-01-05 01:08

    Just keep in mind that mutations have to be synchronous. You can commit directly in components if you (and your team) are sure is there no chance of appearing of something async. In other words, use it with simple and direct operations.

    Committing only in actions as a rule adds some clarity and reliability to application's code.

    I didn't used Redux, but as far as I know, some state managers have middleware. Using mutations and action (Vuex-way) may cause a difficult maintenance into large applications.

    In the future version of Vuex, mutations and actions should be merged into the one entity.

    0 讨论(0)
提交回复
热议问题