From 99dc87e3b4f66491bddba9d9611c29e0272b8307 Mon Sep 17 00:00:00 2001 From: Miljan Aleksic Date: Mon, 25 Apr 2016 14:03:52 +0800 Subject: [PATCH] fix minor typos --- docs/en/tutorial.md | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/docs/en/tutorial.md b/docs/en/tutorial.md index fa011cabc..24794d1cf 100644 --- a/docs/en/tutorial.md +++ b/docs/en/tutorial.md @@ -1,14 +1,14 @@ # Tutorial -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. +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. ![End Result](tutorial/result.png) -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: +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: ### `components/App.vue` -The root component, which contains two other child components: +The root component, which contains two other child components: * `Display` to display the current counter value. * `Increment` which is a button to increment the current value. @@ -65,7 +65,7 @@ export default { ``` -### Challenges without vuex +### Challenges without Vuex * `Increment` and `Display` aren't aware of each other, and cannot pass messages to each other. * `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: ![Vuex Flow](tutorial/vuex_flow.png) -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. +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. ### Step 1: Add a store -The store holds the data for the app. All components read the data from the store. Before we begin, install vuex via npm: +The store holds the data for the app. All components read the data from the store. Before we begin, install Vuex via npm: ``` $ npm install --save vuex @@ -93,10 +93,10 @@ Create a new file in `vuex/store.js` import Vue from 'vue' import Vuex from 'vuex' -// Make vue aware of vuex +// Make vue aware of Vuex Vue.use(Vuex) -// We create an object to hold the initial state when +// Create an object to hold the initial state when // the app starts up const state = { // TODO: Set up our initial state @@ -107,7 +107,7 @@ const mutations = { // TODO: set up our mutations } -// We combine the intial state and the mutations to create a vuex store. +// Combine the initial state and the mutations to create a Vuex store. // This store can be linked to our app. export default new Vuex.Store({ state, @@ -133,8 +133,8 @@ export default { } ``` -> **Tip**: With ES6 and babel you can write it as -> +> **Tip**: With ES6 and babel you can write it as +> > components: { > Display, > Increment, @@ -145,12 +145,12 @@ export default { 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. -Create a new file in `vuex/actions.js` with a single function `incrementCounter` +Create a new file in `vuex/actions.js` with a single function `incrementCounter`. ```js // An action will receive the store as the first argument. // Since we are only interested in the dispatch (and optionally the state) -// We can pull those two parameters using the ES6 destructuring feature +// we can pull those two parameters using the ES6 destructuring feature export const incrementCounter = function ({ dispatch, state }) { dispatch('INCREMENT', 1) } @@ -158,7 +158,7 @@ export const incrementCounter = function ({ dispatch, state }) { And let's call the action from our `components/Increment.vue` component. -``` +```html