This project is archived. Its data is read-only.
Vuex: do we need mutation_types?
Do we get any benefit from mutation types vs simply using strings for mutation names? Here are some reasons that plain strings are preferable to me: 1. **Vuex warns if you commit an action that doesn't exist** This isn't quite as good/useful as the static analysis, but means we can catch this in tests. And we could probably statically analyze check that any `commit()` has a valid mutation as the first argument 2. **We don't use types for `dispatch`. These two lines that should almost identical look very different** ``` dispatch('doThatThing'); commit(types.DO_THAT_THING); ``` 3. **Relatedly, why are we using `UPPER_SNAKE_CASE`?** Makes sense for the mutation_types file, since they are constants. But in the actual mutations file (i.e. the thing that is actual code that we use) we have `FUNCTION_NAMES_FORMATTED_LIKE_THIS` 4. **Save $$$ on keystrokes. Never type `types.` again!** I also don't really like computed keys in objects. Compare: ```js import * as types from './mutation_types'; export default { [types.REQUEST_METRICS_DATA](state) { return 🤮; } } export default { REQUEST_METRICS_DATA(state) { return 😎; } } ``` 5. **Benefits for JetBrains editor users** observation from @winh > at least it jumps to mutations if you click on the strings (which it does not when using mutation types)
issue