Vuex: Why do we write mutations, actions and getters in uppercase?

I am wondering why we are writing the name of the mutation, action and getter function in uppercase? Where did this agreement come from?

export default {
  SOME_MUTATION (state, payload) {

  },

  ANOTHER_MUTATION (state, payload) {

  },
}

      

+3


source to share


1 answer


It is a lengthy coding style for writing constants in all uppercase letters.

In the Vuex documentation:

The commonly observed pattern uses constants for mutation types in various Flux implementations. This allows you to use code from tools such as lint, and putting all the constants in one file allows your employees to get an idea of ​​what mutations are possible throughout the application.



So, this is only really after the long tradition of uppercase naming constants for the most part. This is not required.

Using constants is mostly preferred - this can be useful in large projects with many developers, but it's completely optional if you don't like it.

+5


source







All Articles