You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve documentation consistency for mutations.md and actions.md (#794)
* Improve documentation consistency for `mutations.md`
Signed-off-by: Bruno Lesieur <[email protected]>
* Add mapMutations to ticked text
Signed-off-by: Bruno Lesieur <[email protected]>
* Add review of actions.md to the PR
Signed-off-by: Bruno Lesieur <[email protected]>
* Add ticks to modules.md
Signed-off-by: Bruno Lesieur <[email protected]>
* Add some tick to plugins.md
Signed-off-by: Bruno Lesieur <[email protected]>
Copy file name to clipboardExpand all lines: docs/en/actions.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,13 +107,13 @@ export default {
107
107
// ...
108
108
methods: {
109
109
...mapActions([
110
-
'increment', // map this.increment() to this.$store.dispatch('increment')
110
+
'increment', // map `this.increment()` to `this.$store.dispatch('increment')`
111
111
112
-
// mapActions also supports payloads:
113
-
'incrementBy'// this.incrementBy(amount) maps to this.$store.dispatch('incrementBy', amount)
112
+
//`mapActions` also supports payloads:
113
+
'incrementBy'//map `this.incrementBy(amount)` to `this.$store.dispatch('incrementBy', amount)`
114
114
]),
115
115
...mapActions({
116
-
add:'increment'// map this.add() to this.$store.dispatch('increment')
116
+
add:'increment'// map `this.add()` to `this.$store.dispatch('increment')`
117
117
})
118
118
}
119
119
}
@@ -162,14 +162,14 @@ actions: {
162
162
Finally, if we make use of [async / await](https://tc39.github.io/ecmascript-asyncawait/), a JavaScript feature landing very soon, we can compose our actions like this:
163
163
164
164
```js
165
-
// assuming getData() and getOtherData() return Promises
165
+
// assuming `getData()` and `getOtherData()` return Promises
166
166
167
167
actions: {
168
168
asyncactionA ({ commit }) {
169
169
commit('gotData', awaitgetData())
170
170
},
171
171
asyncactionB ({ dispatch, commit }) {
172
-
awaitdispatch('actionA') // wait for actionA to finish
172
+
awaitdispatch('actionA') // wait for `actionA` to finish
Copy file name to clipboardExpand all lines: docs/en/mutations.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ const store = new Vuex.Store({
16
16
})
17
17
```
18
18
19
-
You cannot directly call a mutation handler. The options here is more like event registration: "When a mutation with type `increment` is triggered, call this handler." To invoke a mutation handler, you need to call **store.commit** with its type:
19
+
You cannot directly call a mutation handler. The options here is more like event registration: "When a mutation with type `increment` is triggered, call this handler." To invoke a mutation handler, you need to call `store.commit` with its type:
20
20
21
21
```js
22
22
store.commit('increment')
@@ -146,13 +146,13 @@ export default {
146
146
// ...
147
147
methods: {
148
148
...mapMutations([
149
-
'increment', // map this.increment() to this.$store.commit('increment')
149
+
'increment', // map `this.increment()` to `this.$store.commit('increment')`
150
150
151
-
// mapMutations also supports payloads:
152
-
'incrementBy' // this.incrementBy(amount) maps to this.$store.commit('incrementBy', amount)
Copy file name to clipboardExpand all lines: docs/en/plugins.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ const myPlugin = store => {
7
7
// called when the store is initialized
8
8
store.subscribe((mutation, state) => {
9
9
// called after every mutation.
10
-
// The mutation comes in the format of { type, payload }.
10
+
// The mutation comes in the format of `{ type, payload }`.
11
11
})
12
12
}
13
13
```
@@ -62,15 +62,15 @@ const myPluginWithSnapshot = store => {
62
62
store.subscribe((mutation, state) => {
63
63
let nextState =_.cloneDeep(state)
64
64
65
-
// compare prevState and nextState...
65
+
// compare `prevState` and `nextState`...
66
66
67
67
// save state for next mutation
68
68
prevState = nextState
69
69
})
70
70
}
71
71
```
72
72
73
-
**Plugins that take state snapshots should be used only during development.** When using Webpack or Browserify, we can let our build tools handle that for us:
73
+
**Plugins that take state snapshots should be used only during development.** When using webpack or Browserify, we can let our build tools handle that for us:
74
74
75
75
```js
76
76
conststore=newVuex.Store({
@@ -81,7 +81,7 @@ const store = new Vuex.Store({
81
81
})
82
82
```
83
83
84
-
The plugin will be used by default. For production, you will need [DefinePlugin](https://webpack.github.io/docs/list-of-plugins.html#defineplugin) for Webpack or [envify](https://github.com/hughsk/envify) for Browserify to convert the value of `process.env.NODE_ENV !== 'production'` to `false` for the final build.
84
+
The plugin will be used by default. For production, you will need [DefinePlugin](https://webpack.github.io/docs/list-of-plugins.html#defineplugin) for webpack or [envify](https://github.com/hughsk/envify) for Browserify to convert the value of `process.env.NODE_ENV !== 'production'` to `false` for the final build.
85
85
86
86
### Built-in Logger Plugin
87
87
@@ -103,8 +103,8 @@ The `createLogger` function takes a few options:
103
103
constlogger=createLogger({
104
104
collapsed:false, // auto-expand logged mutations
105
105
filter (mutation, stateBefore, stateAfter) {
106
-
// returns true if a mutation should be logged
107
-
// `mutation` is a { type, payload }
106
+
// returns `true` if a mutation should be logged
107
+
// `mutation` is a `{ type, payload }`
108
108
returnmutation.type!=="aBlacklistedMutation"
109
109
},
110
110
transformer (state) {
@@ -113,7 +113,7 @@ const logger = createLogger({
113
113
returnstate.subTree
114
114
},
115
115
mutationTransformer (mutation) {
116
-
// mutations are logged in the format of { type, payload }
116
+
// mutations are logged in the format of `{ type, payload }`
0 commit comments