summaryrefslogtreecommitdiff
path: root/doc/development/fe_guide/vuex.md
diff options
context:
space:
mode:
authorMartin Wortschack <mwortschack@gitlab.com>2018-09-11 08:43:10 +0200
committerMartin Wortschack <mwortschack@gitlab.com>2018-09-11 08:43:10 +0200
commita2f7936c74e6c9c4eed7b1c5641f0c43d4ff1375 (patch)
tree82b1ea27fe2a9a1be884467e10d9bde688ce97d1 /doc/development/fe_guide/vuex.md
parentbfd2181310097f5c0a92a43ffc2b7b9540b96ad3 (diff)
parent2f990e3408d00cad473d8dcf8a4e49155cc3cc33 (diff)
downloadgitlab-ce-a2f7936c74e6c9c4eed7b1c5641f0c43d4ff1375.tar.gz
merge master and resolve conflicts
Diffstat (limited to 'doc/development/fe_guide/vuex.md')
-rw-r--r--doc/development/fe_guide/vuex.md33
1 files changed, 17 insertions, 16 deletions
diff --git a/doc/development/fe_guide/vuex.md b/doc/development/fe_guide/vuex.md
index 4089cd37d73..f582f5da323 100644
--- a/doc/development/fe_guide/vuex.md
+++ b/doc/development/fe_guide/vuex.md
@@ -290,23 +290,24 @@ export default {
```
### Vuex Gotchas
-1. Do not call a mutation directly. Always use an action to commit a mutation. Doing so will keep consistency throughout the application. From Vuex docs:
-
- > why don't we just call store.commit('action') directly? Well, remember that mutations must be synchronous? Actions aren't. We can perform asynchronous operations inside an action.
- ```javascript
- // component.vue
-
- // bad
- created() {
- this.$store.commit('mutation');
- }
+1. Do not call a mutation directly. Always use an action to commit a mutation. Doing so will keep consistency throughout the application. From Vuex docs:
- // good
- created() {
- this.$store.dispatch('action');
- }
- ```
+ > why don't we just call store.commit('action') directly? Well, remember that mutations must be synchronous? Actions aren't. We can perform asynchronous operations inside an action.
+
+ ```javascript
+ // component.vue
+
+ // bad
+ created() {
+ this.$store.commit('mutation');
+ }
+
+ // good
+ created() {
+ this.$store.dispatch('action');
+ }
+ ```
1. Use mutation types instead of hardcoding strings. It will be less error prone.
1. The State will be accessible in all components descending from the use where the store is instantiated.
@@ -342,7 +343,7 @@ describe('component', () => {
name: 'Foo',
age: '30',
};
-
+
store = createStore();
// populate the store