Skip to content

Commit e1e4c2e

Browse files
MachinisteWebyyx990803
authored andcommitted
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]>
1 parent 730b369 commit e1e4c2e

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

docs/en/actions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ export default {
107107
// ...
108108
methods: {
109109
...mapActions([
110-
'increment', // map this.increment() to this.$store.dispatch('increment')
110+
'increment', // map `this.increment()` to `this.$store.dispatch('increment')`
111111

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)`
114114
]),
115115
...mapActions({
116-
add: 'increment' // map this.add() to this.$store.dispatch('increment')
116+
add: 'increment' // map `this.add()` to `this.$store.dispatch('increment')`
117117
})
118118
}
119119
}
@@ -162,14 +162,14 @@ actions: {
162162
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:
163163

164164
``` js
165-
// assuming getData() and getOtherData() return Promises
165+
// assuming `getData()` and `getOtherData()` return Promises
166166

167167
actions: {
168168
async actionA ({ commit }) {
169169
commit('gotData', await getData())
170170
},
171171
async actionB ({ dispatch, commit }) {
172-
await dispatch('actionA') // wait for actionA to finish
172+
await dispatch('actionA') // wait for `actionA` to finish
173173
commit('gotOtherData', await getOtherData())
174174
}
175175
}

docs/en/modules.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const store = new Vuex.Store({
2525
}
2626
})
2727

28-
store.state.a // -> moduleA's state
29-
store.state.b // -> moduleB's state
28+
store.state.a // -> `moduleA`'s state
29+
store.state.b // -> `moduleB`'s state
3030
```
3131

3232
### Module Local State
@@ -38,7 +38,7 @@ const moduleA = {
3838
state: { count: 0 },
3939
mutations: {
4040
increment (state) {
41-
// state is the local module state
41+
// `state` is the local module state
4242
state.count++
4343
}
4444
},

docs/en/mutations.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const store = new Vuex.Store({
1616
})
1717
```
1818

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:
2020

2121
``` js
2222
store.commit('increment')
@@ -146,13 +146,13 @@ export default {
146146
// ...
147147
methods: {
148148
...mapMutations([
149-
'increment', // map this.increment() to this.$store.commit('increment')
149+
'increment', // map `this.increment()` to `this.$store.commit('increment')`
150150
151-
// mapMutations also supports payloads:
152-
'incrementBy' // this.incrementBy(amount) maps to this.$store.commit('incrementBy', amount)
151+
// `mapMutations` also supports payloads:
152+
'incrementBy' // map `this.incrementBy(amount)` to `this.$store.commit('incrementBy', amount)`
153153
]),
154154
...mapMutations({
155-
add: 'increment' // map this.add() to this.$store.commit('increment')
155+
add: 'increment' // map `this.add()` to `this.$store.commit('increment')`
156156
})
157157
}
158158
}

docs/en/plugins.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const myPlugin = store => {
77
// called when the store is initialized
88
store.subscribe((mutation, state) => {
99
// called after every mutation.
10-
// The mutation comes in the format of { type, payload }.
10+
// The mutation comes in the format of `{ type, payload }`.
1111
})
1212
}
1313
```
@@ -62,15 +62,15 @@ const myPluginWithSnapshot = store => {
6262
store.subscribe((mutation, state) => {
6363
let nextState = _.cloneDeep(state)
6464

65-
// compare prevState and nextState...
65+
// compare `prevState` and `nextState`...
6666

6767
// save state for next mutation
6868
prevState = nextState
6969
})
7070
}
7171
```
7272

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:
7474

7575
``` js
7676
const store = new Vuex.Store({
@@ -81,7 +81,7 @@ const store = new Vuex.Store({
8181
})
8282
```
8383

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.
8585

8686
### Built-in Logger Plugin
8787

@@ -103,8 +103,8 @@ The `createLogger` function takes a few options:
103103
const logger = createLogger({
104104
collapsed: false, // auto-expand logged mutations
105105
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 }`
108108
return mutation.type !== "aBlacklistedMutation"
109109
},
110110
transformer (state) {
@@ -113,7 +113,7 @@ const logger = createLogger({
113113
return state.subTree
114114
},
115115
mutationTransformer (mutation) {
116-
// mutations are logged in the format of { type, payload }
116+
// mutations are logged in the format of `{ type, payload }`
117117
// we can format it any way we want.
118118
return mutation.type
119119
}

0 commit comments

Comments
 (0)