Просмотр исходного кода

Improve documentation consistency for `mutations.md` and `actions.md` (#794)

* Improve documentation consistency for `mutations.md`

Signed-off-by: Bruno Lesieur <bruno.lesieur@gmail.com>

* Add mapMutations to ticked text

Signed-off-by: Bruno Lesieur <bruno.lesieur@gmail.com>

* Add review of actions.md to the PR

Signed-off-by: Bruno Lesieur <bruno.lesieur@gmail.com>

* Add ticks to modules.md

Signed-off-by: Bruno Lesieur <bruno.lesieur@gmail.com>

* Add some tick to plugins.md

Signed-off-by: Bruno Lesieur <bruno.lesieur@gmail.com>
Bruno Lesieur 8 лет назад
Родитель
Сommit
e1e4c2e2b2
4 измененных файлов с 21 добавлено и 21 удалено
  1. 6 6
      docs/en/actions.md
  2. 3 3
      docs/en/modules.md
  3. 5 5
      docs/en/mutations.md
  4. 7 7
      docs/en/plugins.md

+ 6 - 6
docs/en/actions.md

@@ -107,13 +107,13 @@ export default {
   // ...
   // ...
   methods: {
   methods: {
     ...mapActions([
     ...mapActions([
-      'increment', // map this.increment() to this.$store.dispatch('increment')
+      'increment', // map `this.increment()` to `this.$store.dispatch('increment')`
       
       
-      // mapActions also supports payloads:
-      'incrementBy' // this.incrementBy(amount) maps to this.$store.dispatch('incrementBy', amount)
+      // `mapActions` also supports payloads:
+      'incrementBy' // map `this.incrementBy(amount)` to `this.$store.dispatch('incrementBy', amount)`
     ]),
     ]),
     ...mapActions({
     ...mapActions({
-      add: 'increment' // map this.add() to this.$store.dispatch('increment')
+      add: 'increment' // map `this.add()` to `this.$store.dispatch('increment')`
     })
     })
   }
   }
 }
 }
@@ -162,14 +162,14 @@ actions: {
 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:
 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:
 
 
 ``` js
 ``` js
-// assuming getData() and getOtherData() return Promises
+// assuming `getData()` and `getOtherData()` return Promises
 
 
 actions: {
 actions: {
   async actionA ({ commit }) {
   async actionA ({ commit }) {
     commit('gotData', await getData())
     commit('gotData', await getData())
   },
   },
   async actionB ({ dispatch, commit }) {
   async actionB ({ dispatch, commit }) {
-    await dispatch('actionA') // wait for actionA to finish
+    await dispatch('actionA') // wait for `actionA` to finish
     commit('gotOtherData', await getOtherData())
     commit('gotOtherData', await getOtherData())
   }
   }
 }
 }

+ 3 - 3
docs/en/modules.md

@@ -25,8 +25,8 @@ const store = new Vuex.Store({
   }
   }
 })
 })
 
 
-store.state.a // -> moduleA's state
-store.state.b // -> moduleB's state
+store.state.a // -> `moduleA`'s state
+store.state.b // -> `moduleB`'s state
 ```
 ```
 
 
 ### Module Local State
 ### Module Local State
@@ -38,7 +38,7 @@ const moduleA = {
   state: { count: 0 },
   state: { count: 0 },
   mutations: {
   mutations: {
     increment (state) {
     increment (state) {
-      // state is the local module state
+      // `state` is the local module state
       state.count++
       state.count++
     }
     }
   },
   },

+ 5 - 5
docs/en/mutations.md

@@ -16,7 +16,7 @@ const store = new Vuex.Store({
 })
 })
 ```
 ```
 
 
-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:
+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:
 
 
 ``` js
 ``` js
 store.commit('increment')
 store.commit('increment')
@@ -146,13 +146,13 @@ export default {
   // ...
   // ...
   methods: {
   methods: {
     ...mapMutations([
     ...mapMutations([
-      'increment', // map this.increment() to this.$store.commit('increment')
+      'increment', // map `this.increment()` to `this.$store.commit('increment')`
       
       
-      // mapMutations also supports payloads:
-      'incrementBy' // this.incrementBy(amount) maps to this.$store.commit('incrementBy', amount)
+      // `mapMutations` also supports payloads:
+      'incrementBy' // map `this.incrementBy(amount)` to `this.$store.commit('incrementBy', amount)`
     ]),
     ]),
     ...mapMutations({
     ...mapMutations({
-      add: 'increment' // map this.add() to this.$store.commit('increment')
+      add: 'increment' // map `this.add()` to `this.$store.commit('increment')`
     })
     })
   }
   }
 }
 }

+ 7 - 7
docs/en/plugins.md

@@ -7,7 +7,7 @@ const myPlugin = store => {
   // called when the store is initialized
   // called when the store is initialized
   store.subscribe((mutation, state) => {
   store.subscribe((mutation, state) => {
     // called after every mutation.
     // called after every mutation.
-    // The mutation comes in the format of { type, payload }.
+    // The mutation comes in the format of `{ type, payload }`.
   })
   })
 }
 }
 ```
 ```
@@ -62,7 +62,7 @@ const myPluginWithSnapshot = store => {
   store.subscribe((mutation, state) => {
   store.subscribe((mutation, state) => {
     let nextState = _.cloneDeep(state)
     let nextState = _.cloneDeep(state)
 
 
-    // compare prevState and nextState...
+    // compare `prevState` and `nextState`...
 
 
     // save state for next mutation
     // save state for next mutation
     prevState = nextState
     prevState = nextState
@@ -70,7 +70,7 @@ const myPluginWithSnapshot = store => {
 }
 }
 ```
 ```
 
 
-**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:
+**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:
 
 
 ``` js
 ``` js
 const store = new Vuex.Store({
 const store = new Vuex.Store({
@@ -81,7 +81,7 @@ const store = new Vuex.Store({
 })
 })
 ```
 ```
 
 
-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.
+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.
 
 
 ### Built-in Logger Plugin
 ### Built-in Logger Plugin
 
 
@@ -103,8 +103,8 @@ The `createLogger` function takes a few options:
 const logger = createLogger({
 const logger = createLogger({
   collapsed: false, // auto-expand logged mutations
   collapsed: false, // auto-expand logged mutations
   filter (mutation, stateBefore, stateAfter) {
   filter (mutation, stateBefore, stateAfter) {
-    // returns true if a mutation should be logged
-    // `mutation` is a { type, payload }
+    // returns `true` if a mutation should be logged
+    // `mutation` is a `{ type, payload }`
     return mutation.type !== "aBlacklistedMutation"
     return mutation.type !== "aBlacklistedMutation"
   },
   },
   transformer (state) {
   transformer (state) {
@@ -113,7 +113,7 @@ const logger = createLogger({
     return state.subTree
     return state.subTree
   },
   },
   mutationTransformer (mutation) {
   mutationTransformer (mutation) {
-    // mutations are logged in the format of { type, payload }
+    // mutations are logged in the format of `{ type, payload }`
     // we can format it any way we want.
     // we can format it any way we want.
     return mutation.type
     return mutation.type
   }
   }