diff --git a/docs/en/actions.md b/docs/en/actions.md index 3875ff831..859c27892 100644 --- a/docs/en/actions.md +++ b/docs/en/actions.md @@ -107,13 +107,13 @@ export default { // ... methods: { ...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({ - 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: ``` js -// assuming getData() and getOtherData() return Promises +// assuming `getData()` and `getOtherData()` return Promises actions: { async actionA ({ commit }) { commit('gotData', await getData()) }, async actionB ({ dispatch, commit }) { - await dispatch('actionA') // wait for actionA to finish + await dispatch('actionA') // wait for `actionA` to finish commit('gotOtherData', await getOtherData()) } } diff --git a/docs/en/modules.md b/docs/en/modules.md index 5a238b371..ecaa61225 100644 --- a/docs/en/modules.md +++ b/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 @@ -38,7 +38,7 @@ const moduleA = { state: { count: 0 }, mutations: { increment (state) { - // state is the local module state + // `state` is the local module state state.count++ } }, diff --git a/docs/en/mutations.md b/docs/en/mutations.md index ae431d1de..82daabb7d 100644 --- a/docs/en/mutations.md +++ b/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 store.commit('increment') @@ -146,13 +146,13 @@ export default { // ... methods: { ...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({ - add: 'increment' // map this.add() to this.$store.commit('increment') + add: 'increment' // map `this.add()` to `this.$store.commit('increment')` }) } } diff --git a/docs/en/plugins.md b/docs/en/plugins.md index 4d7e64a37..b0fb1356f 100644 --- a/docs/en/plugins.md +++ b/docs/en/plugins.md @@ -7,7 +7,7 @@ const myPlugin = store => { // called when the store is initialized store.subscribe((mutation, state) => { // 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) => { let nextState = _.cloneDeep(state) - // compare prevState and nextState... + // compare `prevState` and `nextState`... // save state for next mutation 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 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 @@ -103,8 +103,8 @@ The `createLogger` function takes a few options: const logger = createLogger({ collapsed: false, // auto-expand logged mutations 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" }, transformer (state) { @@ -113,7 +113,7 @@ const logger = createLogger({ return state.subTree }, 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. return mutation.type }