Skip to content

Commit 02d8bb0

Browse files
committed
Merge pull request #160 from miljan-aleksic/feature/tutorial_update
fix minor typos
2 parents 4c63398 + 99dc87e commit 02d8bb0

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

docs/en/tutorial.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Tutorial
22

3-
Let's build a very simple app using vuex to understand how to use it. For this example, we're building an app where you press a button, and it increments a counter.
3+
Let's build a very simple app using Vuex to understand how to use it. For this example, we're building an app where you press a button, and it increments a counter.
44

55
![End Result](tutorial/result.png)
66

7-
We are using this simple example to explain the concepts, and the problems vuex aims to solve - how to manage a large app which uses several components. Consider if this example used three components:
7+
We are using this simple example to explain the concepts, and the problems Vuex aims to solve - how to manage a large app which uses several components. Consider if this example used three components:
88

99
### `components/App.vue`
1010

11-
The root component, which contains two other child components:
11+
The root component, which contains two other child components:
1212

1313
* `Display` to display the current counter value.
1414
* `Increment` which is a button to increment the current value.
@@ -65,7 +65,7 @@ export default {
6565
</script>
6666
```
6767

68-
### Challenges without vuex
68+
### Challenges without Vuex
6969

7070
* `Increment` and `Display` aren't aware of each other, and cannot pass messages to each other.
7171
* `App` will have to use events and broadcasts to coordinate the two components.
@@ -77,11 +77,11 @@ These are the steps that take place in order:
7777

7878
![Vuex Flow](tutorial/vuex_flow.png)
7979

80-
This might seem a little excessive for incrementing a counter. But do note that these concepts work well in larger applications, improving maintainability and making your app easier to debug and improve in the long run. So let's modify our code to use vuex.
80+
This might seem a little excessive for incrementing a counter. But do note that these concepts work well in larger applications, improving maintainability and making your app easier to debug and improve in the long run. So let's modify our code to use Vuex.
8181

8282
### Step 1: Add a store
8383

84-
The store holds the data for the app. All components read the data from the store. Before we begin, install vuex via npm:
84+
The store holds the data for the app. All components read the data from the store. Before we begin, install Vuex via npm:
8585

8686
```
8787
$ npm install --save vuex
@@ -93,10 +93,10 @@ Create a new file in `vuex/store.js`
9393
import Vue from 'vue'
9494
import Vuex from 'vuex'
9595

96-
// Make vue aware of vuex
96+
// Make vue aware of Vuex
9797
Vue.use(Vuex)
9898

99-
// We create an object to hold the initial state when
99+
// Create an object to hold the initial state when
100100
// the app starts up
101101
const state = {
102102
// TODO: Set up our initial state
@@ -107,7 +107,7 @@ const mutations = {
107107
// TODO: set up our mutations
108108
}
109109

110-
// We combine the intial state and the mutations to create a vuex store.
110+
// Combine the initial state and the mutations to create a Vuex store.
111111
// This store can be linked to our app.
112112
export default new Vuex.Store({
113113
state,
@@ -133,8 +133,8 @@ export default {
133133
}
134134
```
135135

136-
> **Tip**: With ES6 and babel you can write it as
137-
>
136+
> **Tip**: With ES6 and babel you can write it as
137+
>
138138
> components: {
139139
> Display,
140140
> Increment,
@@ -145,20 +145,20 @@ export default {
145145

146146
The action is a function which is called from the component. Action functions can trigger updates in the store by dispatching the right mutation. An action can also talk to HTTP backends and read other data from the store before dispatching updates.
147147

148-
Create a new file in `vuex/actions.js` with a single function `incrementCounter`
148+
Create a new file in `vuex/actions.js` with a single function `incrementCounter`.
149149

150150
```js
151151
// An action will receive the store as the first argument.
152152
// Since we are only interested in the dispatch (and optionally the state)
153-
// We can pull those two parameters using the ES6 destructuring feature
153+
// we can pull those two parameters using the ES6 destructuring feature
154154
export const incrementCounter = function ({ dispatch, state }) {
155155
dispatch('INCREMENT', 1)
156156
}
157157
```
158158

159159
And let's call the action from our `components/Increment.vue` component.
160160

161-
```
161+
```html
162162
<template>
163163
<div>
164164
<button @click='increment'>Increment +1</button>
@@ -179,10 +179,10 @@ export default {
179179

180180
Notice some interesting things about what we just added.
181181

182-
1. We have a new object `vuex.actions` which includes the new action
182+
1. We have a new object `vuex.actions` which includes the new action.
183183
2. We didn't specify which store, object, state, etc. Vuex wires everything up for us.
184-
3. We can call the action either by using `this.increment()` in any method.
185-
4. We can also call the action using the `@click` parameter making `increment` like any regular vue component method.
184+
3. We can call the action by using `this.increment()` in any method.
185+
4. We can also call the action using the `@click` parameter making `increment` like any regular Vue component method.
186186
5. The action is called `incrementCounter` but we can use any name which is appropriate.
187187

188188
### Step 3: Set up the state and mutation
@@ -198,7 +198,7 @@ const state = {
198198
}
199199

200200
const mutations = {
201-
// A mutation recieves the current state as the first argument
201+
// A mutation receives the current state as the first argument
202202
// You can make any modifications you want inside this function
203203
INCREMENT (state, amount) {
204204
state.count = state.count + amount
@@ -252,15 +252,14 @@ You might be wondering - why did we choose to use a getter instead of directly a
252252
2. Many components in a larger app can use the same getter function.
253253
3. If the value is moved from say `store.count` to `store.counter.value` you'd have to update one getter instead of dozens of components.
254254

255-
These are a few of the benefits of using getters.
255+
These are a few of the benefits of using getters.
256256

257257
### Step 5: Next steps
258258

259259
If you run the application, now you will find it behaves as expected.
260260

261-
To further your understanding of vuex, you can try implementing the following changes to the app, as an exercise.
261+
To further your understanding of Vuex, you can try implementing the following changes to the app, as an exercise.
262262

263263
* Add a decrement button.
264-
* Install [VueJS Devtools](https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd?hl=en) and play with the vuex tools and observe the mutations being applied.
265-
* Add a text input in another component called `IncrementAmount` and enter the amount to increment by. This can be a bit tricky since forms in vuex work slightly differently. Read the [Form Handling](forms.md) section for more details.
266-
264+
* Install [VueJS Devtools](https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd?hl=en) and play with the Vuex tools and observe the mutations being applied.
265+
* Add a text input in another component called `IncrementAmount` and enter the amount to increment by. This can be a bit tricky since forms in Vuex work slightly differently. Read the [Form Handling](forms.md) section for more details.

0 commit comments

Comments
 (0)